5.3. AMQ Broker サンプルプログラムの実行

AMQ Broker には、製品の基本的な機能と高度な機能を示す多くのサンプルプログラムが同梱されています。Maven を使用してこれらのプログラムを実行します。

前提条件

手順

  1. 実行する例のディレクトリーに移動します。

    このプログラムの例は <install_dir>/examples にあります。以下に例を示します。

    $ cd <install_dir>/examples/features/standard/queue
  2. mvn clean verify コマンドを使用して、サンプルプログラムを実行します。

    Maven はブローカーを起動し、サンプルプログラムを実行します。サンプルプログラムの初回実行時に、Maven は不足している依存関係をダウンロードします。この処理には時間がかかる場合があります。

    この場合は、queue のサンプルプログラムが実行します。これにより、プロデューサーが作成され、テストメッセージが送信されてから、メッセージを受信するコンシューマーが作成されます。

    $ mvn clean verify
    [INFO] Scanning for projects...
    [INFO]
    [INFO] -------------< org.apache.activemq.examples.broker:queue >--------------
    [INFO] Building ActiveMQ Artemis JMS Queue Example 2.6.1.amq-720004-redhat-1
    [INFO] --------------------------------[ jar ]---------------------------------
    ...
    server-out:2018-12-05 16:37:57,023 INFO  [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.6.1.amq-720004-redhat-1 [0.0.0.0, nodeID=06f529d3-f8d6-11e8-9bea-0800271b03bd]
    [INFO] Server started
    [INFO]
    [INFO] --- artemis-maven-plugin:2.6.1.amq-720004-redhat-1:runClient (runClient) @ queue ---
    Sent message: This is a text message
    Received message: This is a text message
    [INFO]
    [INFO] --- artemis-maven-plugin:2.6.1.amq-720004-redhat-1:cli (stop) @ queue ---
    server-out:2018-12-05 16:37:59,519 INFO  [org.apache.activemq.artemis.core.server] AMQ221002: Apache ActiveMQ Artemis Message Broker version 2.6.1.amq-720004-redhat-1 [06f529d3-f8d6-11e8-9bea-0800271b03bd] stopped, uptime 3.734 seconds
    server-out:Server stopped!
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  48.681 s
    [INFO] Finished at: 2018-12-05T16:37:59-05:00
    [INFO] ------------------------------------------------------------------------
    注記

    一部のサンプルプログラムは UDP クラスタリングを使用しますが、デフォルトではお使いの環境で機能しない場合があります。これらの例を正常に実行するには、224.0.0.0 に送付されたトラフィックをループバックインターフェイスにリダイレクトします。

    $ sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev lo