第 13 章 使用 JMS 代理部署
摘要
Fuse 7.11 不提供默认的内部代理,但设计为与四个外部 JMS 代理进行接口。
Fuse 7.11 容器包含受支持的外部代理的代理客户端库。
有关在 Fuse 7.11 上可用的外部代理、客户端和 Camel 组件组合的更多信息,请参阅支持的配置。https://access.redhat.com/articles/310603
13.1. AMQ 7 快速入门
提供了快速入门来演示使用 AMQ 7 代理的应用程序设置和部署。
下载快速入门
您可从 Fuse Software Downloads 页面安装所有快速入门。
将下载的 zip 文件的内容提取到本地文件夹,例如:名为 Quickstart 的文件夹。
设置快速入门
-
导航到
快速入门/camel/camel-jms
文件夹。 -
输入
mvn clean install
来构建 quickstart。 -
将文件
org.ops4j.connectionfactory-amq7.cfg
从/camel/camel-jms/src/main
目录复制到 Fuse 安装中的FUSE_HOME/etc
目录。验证其内容是否正确代理 URL 和凭证。默认情况下,代理 URL 设置为 AMQ 7 的 CORE 协议的 tcp://localhost:61616。凭证设置为 admin/admin。更改这些详情以适应外部代理。 -
通过在 Linux 或 Windows 上运行
bin\fuse.bat
上运行./bin/fuse
.bat 来启动 Fuse。 在 Fuse 控制台中输入以下命令:
feature:install pax-jms-pool artemis-jms-client camel-blueprint camel-jms install -s mvn:org.jboss.fuse.quickstarts/camel-jms/${project.version}
当部署捆绑包时,Fuse 将为您提供捆绑包 ID。
-
输入
log:display
以查看启动日志信息。检查以确保捆绑包已部署成功。
12:13:50.445 INFO [Blueprint Event Dispatcher: 1] Attempting to start Camel Context jms-example-context 12:13:50.446 INFO [Blueprint Event Dispatcher: 1] Apache Camel 2.21.0.fuse-000030 (CamelContext: jms-example-context) is starting 12:13:50.446 INFO [Blueprint Event Dispatcher: 1] JMX is enabled 12:13:50.528 INFO [Blueprint Event Dispatcher: 1] StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html 12:13:50.553 INFO [Blueprint Event Dispatcher: 1] Route: file-to-jms-route started and consuming from: file://work/jms/input 12:13:50.555 INFO [Blueprint Event Dispatcher: 1] Route: jms-cbr-route started and consuming from: jms://queue:incomingOrders?transacted=true 12:13:50.556 INFO [Blueprint Event Dispatcher: 1] Total 2 routes, of which 2 are started
运行快速入门
-
当 Camel 路由运行时,将创建
/camel/camel-jms/work/jms/input
目录。将/camel/camel-jms/src/main/data
目录中的文件复制到/camel/camel-jms/work/input
目录中。 复制到
…/src/main/data
文件中的文件是订购文件。等待一分钟,然后检查/camel/camel-jms/work/jms/output
目录。文件将根据目的地的国家/地区排序为独立目录:-
order1.xml
、order2.xml
和order4.xml
in/camel/camel-jms/work/jms/outputs/
-
order3.xml
和order5.xml
在/camel/camel-jms/work/jms/output/us
中 -
order6.xml
in/camel/camel-jms/work/jms/output/fr
-
-
使用
log:display
查看日志信息:
Receiving order order1.xml Sending order order1.xml to another country Done processing order1.xml
- Camel 命令将显示上下文的详细信息:
使用 camel:context-list
显示上下文详情:
Context Status Total # Failed # Inflight # Uptime ------- ------ ------- -------- ---------- ------ jms-example-context Started 12 0 0 3 minutes
使用 camel:route-list
在上下文中显示 Camel 路由:
Context Route Status Total # Failed # Inflight # Uptime ------- ----- ------ ------- -------- ---------- ------ jms-example-context file-to-jms-route Started 6 0 0 3 minutes jms-example-context jms-cbr-route Started 6 0 0 3 minutes
使用 camel:route-info
显示交换统计信息:
karaf@root()> camel:route-info jms-cbr-route jms-example-context Camel Route jms-cbr-route Camel Context: jms-example-context State: Started State: Started Statistics Exchanges Total: 6 Exchanges Completed: 6 Exchanges Failed: 0 Exchanges Inflight: 0 Min Processing Time: 2 ms Max Processing Time: 12 ms Mean Processing Time: 4 ms Total Processing Time: 29 ms Last Processing Time: 4 ms Delta Processing Time: 1 ms Start Statistics Date: 2018-01-30 12:13:50 Reset Statistics Date: 2018-01-30 12:13:50 First Exchange Date: 2018-01-30 12:19:47 Last Exchange Date: 2018-01-30 12:19:47