第8章 Camel アプリケーションの A-MQ ブローカーとの統合
このチュートリアルでは、A-MQ イメージを使用してクイックスタートをデプロイする方法を説明します。
8.1. Spring Boot Camel A-MQ クイックスタートのビルドおよびデプロイ
このクイックスタートでは、Spring Boot アプリケーションを AMQ Online に接続する方法と、Fuse on OpenShift を使用して 2 つの Camel ルートの間で JMS メッセージングを使用する方法を実証します。
前提条件
- AMQ Online がデプロイされ、稼働しているようにしてください。AMQ Online を OpenShift にインストールするには、Installing and configuring AMQ Online on OpenShift を参照してください。
- OpenShift が適切に稼働し、Fuse イメージストリームがすでに OpenShift にインストールされている。管理者向けの基本情報 を参照してください。
- Maven リポジトリーが Fuse に対して設定されているようにしてください。詳細は Maven リポジトリーの設定 を参照してください。
手順
開発者として OpenShift サーバーにログインします。
oc login -u developer -p developer
openshift
プロジェクトにログインします。oc project openshift
Maven ワークフローを使用して、クイックスタートプロジェクトを作成します。
mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \ -DarchetypeCatalog=https://maven.repository.redhat.com/ga/io/fabric8/archetypes/archetypes-catalog/2.2.0.fuse-760024-redhat-00001/archetypes-catalog-2.2.0.fuse-760024-redhat-00001-archetype-catalog.xml \ -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \ -DarchetypeArtifactId=spring-boot-camel-amq-archetype \ -DarchetypeVersion=2.2.0.fuse-760024-redhat-00001
archetype プラグインが対話モードに切り替わり、残りのフィールドの入力を要求されます。
Define value for property 'groupId': : org.example.fis Define value for property 'artifactId': : fuse76-spring-boot-camel-amq Define value for property 'version': 1.0-SNAPSHOT: : Define value for property 'package': org.example.fis: : Confirm properties configuration: groupId: org.example.fis artifactId: fuse76-spring-boot-camel-amq version: 1.0-SNAPSHOT package: org.example.fis Y: :Y
プロンプトが表示されたら、
org.example.fis
をgroupId
の値として入力し、fuse76-spring-boot-camel-amq
をartifactId
の値として入力します。残りのフィールドではデフォルト値を使用します。クイックスタートディレクトリー
fuse76-spring-boot-camel-amq
に移動します。cd fuse76-spring-boot-camel-amq
以下のコマンドを実行し、設定ファイルを AMQ Online に適用します。これらの設定ファイルによって、管理者権限を持つ AMQ Online ユーザーおよびキューが作成されます。
oc login -u system:admin oc apply -f src/main/resources/k8s
mvn
コマンドを実行し、クイックスタートを OpenShift サーバーにデプロイします。mvn fabric8:deploy -Popenshift
クイックスタートが正常に実行されていることを確認するには、以下を行います。
- ブラウザーで https://OPENSHIFT_IP_ADDR の OpenShift Web コンソールに移動します。OPENSHIFT_IP_ADDR はクラスターの IP アドレスに置き換えます。クレデンシャル (例: ユーザー名 developer、パスワード developer) を使用して、コンソールにログインします。
-
左側のパネルで
Home
をデプロイメントし、Status
をクリックしてopenshift
プロジェクトの Project Status ページを表示します。 -
fuse76-spring-boot-camel-amq
をクリックし、クイックスタートの概要情報ページを表示します。 -
左側のパネルで、
Workloads
を展開します。 -
Pods
をクリックした後、fuse76-spring-boot-camel-amq-xxxxx
をクリックします。クイックスタートの Pod の詳細が表示されます。 Logs
をクリックし、アプリケーションのログを確認します。出力にはメッセージが正常に送信されたことが表示されます。
10:17:59.825 [Camel (camel) thread #10 - timer://order] INFO generate-order-route - Generating order order1379.xml 10:17:59.829 [Camel (camel) thread #8 - JmsConsumer[incomingOrders]] INFO jms-cbr-route - Sending order order1379.xml to the UK 10:17:59.829 [Camel (camel) thread #8 - JmsConsumer[incomingOrders]] INFO jms-cbr-route - Done processing order1379.xml 10:18:02.825 [Camel (camel) thread #10 - timer://order] INFO generate-order-route - Generating order order1380.xml 10:18:02.829 [Camel (camel) thread #7 - JmsConsumer[incomingOrders]] INFO jms-cbr-route - Sending order order1380.xml to another country 10:18:02.829 [Camel (camel) thread #7 - JmsConsumer[incomingOrders]] INFO jms-cbr-route - Done processing order1380.xml
- Web インターフェイスでルートを表示するには、Open Java Console をクリックし、AMQ キューのメッセージをチェックします。