Camel之JMS路由

匿名 (未验证) 提交于 2019-12-03 00:34:01

JMSqueue,queue.

Camel:,queue.(Camel in Action)

1,因为要用JMS,这里介绍一个open source的activeMQ,可以从http://activemq.apache.org/download.html 下载,下载后解压,bin目录有一个activemq.bat文件,在命令行里运行activemq 启动activeMQ,如果能从从浏览器里访问 http://localhost:8161/admin/activeMQ成功启动了.

2,在Camel里实现上图所示的路由:JAVAactiveMQ的jar包配置到classpath下,Java代码如下:

privatestatic

privatestatic

privatestatic

publicstaticvoidthrows

new

new

"jms"

new

publicvoid

"file:d:/temp/inbox"

"jms:queue:TOOL.DEFAULT"

booleantrue

while

25000

Camelbinary messageactiveMQ'TOOL.DEFAULT'queue .

textmessage:from("file:d:/temp/inbox").convertBodyTo(String.class).to("jms:queue:TOOL.DEFAULT");

Camelqueue.

privatestatic

privatestatic

privatestatic

privatestaticboolean

privatestaticint

publicstaticvoidthrows

new

"TOOL.DEFAULT"

1000

ifinstanceof

elseifnull

bytenewbyte[(int

new

}

,上面的路由也可以通过Spring配置实现:

<beanid="jms"class="org.apache.camel.component.jms.JmsComponent">

<propertyname="connectionFactory">

<beanclass="org.apache.activemq.ActiveMQConnectionFactory">

<propertyname="brokerURL"value="failover://tcp://localhost:61616"/>

</bean>

</property>

</bean>

<camelContextxmlns="http://camel.apache.org/schema/spring">

<route>

<fromuri="file:d:/temp/inbox"/>

<touri="jms:queue:TOOL.DEFAULT"/>

</route>

</camelContext>

文章来源: Camel之JMS路由
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!