3.2. 最初のサンプルの実行
この例では、exampleQueue
という名前のキューにコンシューマーおよびプロデューサーを作成します。テキストメッセージを送信してから受信し、受信したメッセージをコンソールに出力します。
手順
<install-dir>/examples/features/standard/queue
ディレクトリーで以下のコマンドを実行し、Maven を使用してサンプルを構築します。$ mvn clean package dependency:copy-dependencies -DincludeScope=runtime -DskipTests
dependency:copy-dependencies
を追加すると、依存関係がtarget/dependency
ディレクトリーにコピーされます。java
コマンドを使用して例を実行します。Linux または UNIX の場合:
$ java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExample
Windows の場合:
> java -cp "target\classes;target\dependency\*" org.apache.activemq.artemis.jms.example.QueueExample
たとえば、Linux で実行すると、以下のような出力になります。
$ java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExample Sent message: This is a text message Received message: This is a text message
この例のソースコードは <install-dir>/examples/features/standard/queue/src
ディレクトリーにあります。追加の例は、<install-dir>/examples/features/standard
ディレクトリーにあります。