如何使用 Camel 从远程 WMQ 获取消息并将消息放入 ActiveMQ?
How to use Camel to get message from remote WMQ and place message in ActiveMQ?
我已经看了好几天了,但仍然没有成功。
我已经在服务器上安装 运行 activeMQ。创建了一个名为 "testUpdate" 的队列。我在另一台服务器上还有另一个队列,我们称之为 "forward",这是在 IBM MQ (WMQ) 上。
所以我们在 ActiveMQ 上有 testUpdate,在 WMQ 上有 forward。我希望 forward 队列中的消息被放入 testUpdate 队列中。尝试在此过程中使用 Camel。
所以 ActiveMQ 中的设置有一个 XML(activemq.xml),我可以放置 spring bean 并配置它来执行路由。在这个 xml 中,我将 http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd 添加到 xmlns 然后添加
导入资源="camel.xml"
在这个新 xml 中,我有以下内容:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<description>Example Camel Route</description>
<from uri="mqseries:forward"/>
<to uri="activemq:testUpdate"/>
</route>
</camelContext>
<bean id="mqseries" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1"/>
<property name="hostName" value="172.00.12.21/>
<property name="port" value="xyza"/>
<property name="queueManager" value="manager"/>
<property name="channel" value="srvcChannel"/>
</bean>
<!--
Lets configure some Camel endpoints
http://camel.apache.org/components.html
-->
<!-- configure the camel activemq component to use the current broker -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://amq-broker?create=false"/>
<property name="userName" value="${activemq.username}"/>
<property name="password" value="${activemq.password}"/>
</bean>
</property>
</bean>
</beans>
我将jar 文件com.ibm.mq.allclient.jar 添加到ActiveMQ 的lib 文件夹中。当 运行ning 程序时,我得到这个异常:
java.lang.ClassNotFoundException: javax.jms.JMSRuntimeException
我好像缺少 websphere jar 文件?这是正确的吗?
您可以使用 jms 组件使用来自 IBM MQ 的消息,并使用 activemq 组件 post 将其发送到 ActiveMQ
查看以下链接
http://camel.apache.org/jms.html
http://camel.apache.org/activemq.html
谢谢,
义武
我经常使用 IBM MQ 和 ActiveMQ。下面的示例将向您展示一些示例配置选项。请确保您将这些配置为您自己的用例。
//ActiveMQ connection factory
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" destroy-method="doStop">
<property name="configuration">
<bean class="org.apache.camel.component.jms.JmsConfiguration">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="acceptMessagesWhileStopping" value="true" />
<property name="acknowledgementModeName" value="CLIENT_ACKNOWLEDGE" />
<property name="cacheLevelName" value="CACHE_CONSUMER" />
<property name="connectionFactory">
<bean class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="1" />
<property name="MaximumActiveSessionPerConnection" value="500" />
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq1.brokerUrl}" />
<property name="userName" value="${activemq1.username}" />
<property name="password" value="${activemq1.password}" />
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
//IBM MQ connection factory
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent" destroy-method="doStop">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="connectionFactory">
<bean class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy">
<constructor-arg>
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1" />
<property name="channel" value="${channel}" />
<property name="hostName" value="${hostname}" />
<property name="port" value="${port}" />
<property name="queueManager" value="${queueManager}" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
您可以使用用户 camel 额外组件 https://github.com/camel-extra/camel-extra/blob/master/components/camel-wmq/README.md to get messages from wmq without using the JMS wrapping and then send messages to ActiveMQ with custom camel component https://camel.apache.org/components/latest/activemq-component.html. See also a similar topic 。
我已经看了好几天了,但仍然没有成功。
我已经在服务器上安装 运行 activeMQ。创建了一个名为 "testUpdate" 的队列。我在另一台服务器上还有另一个队列,我们称之为 "forward",这是在 IBM MQ (WMQ) 上。
所以我们在 ActiveMQ 上有 testUpdate,在 WMQ 上有 forward。我希望 forward 队列中的消息被放入 testUpdate 队列中。尝试在此过程中使用 Camel。
所以 ActiveMQ 中的设置有一个 XML(activemq.xml),我可以放置 spring bean 并配置它来执行路由。在这个 xml 中,我将 http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd 添加到 xmlns 然后添加
导入资源="camel.xml"
在这个新 xml 中,我有以下内容:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<description>Example Camel Route</description>
<from uri="mqseries:forward"/>
<to uri="activemq:testUpdate"/>
</route>
</camelContext>
<bean id="mqseries" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1"/>
<property name="hostName" value="172.00.12.21/>
<property name="port" value="xyza"/>
<property name="queueManager" value="manager"/>
<property name="channel" value="srvcChannel"/>
</bean>
<!--
Lets configure some Camel endpoints
http://camel.apache.org/components.html
-->
<!-- configure the camel activemq component to use the current broker -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://amq-broker?create=false"/>
<property name="userName" value="${activemq.username}"/>
<property name="password" value="${activemq.password}"/>
</bean>
</property>
</bean>
</beans>
我将jar 文件com.ibm.mq.allclient.jar 添加到ActiveMQ 的lib 文件夹中。当 运行ning 程序时,我得到这个异常: java.lang.ClassNotFoundException: javax.jms.JMSRuntimeException
我好像缺少 websphere jar 文件?这是正确的吗?
您可以使用 jms 组件使用来自 IBM MQ 的消息,并使用 activemq 组件 post 将其发送到 ActiveMQ
查看以下链接
http://camel.apache.org/jms.html http://camel.apache.org/activemq.html
谢谢, 义武
我经常使用 IBM MQ 和 ActiveMQ。下面的示例将向您展示一些示例配置选项。请确保您将这些配置为您自己的用例。
//ActiveMQ connection factory
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" destroy-method="doStop">
<property name="configuration">
<bean class="org.apache.camel.component.jms.JmsConfiguration">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="acceptMessagesWhileStopping" value="true" />
<property name="acknowledgementModeName" value="CLIENT_ACKNOWLEDGE" />
<property name="cacheLevelName" value="CACHE_CONSUMER" />
<property name="connectionFactory">
<bean class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="1" />
<property name="MaximumActiveSessionPerConnection" value="500" />
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq1.brokerUrl}" />
<property name="userName" value="${activemq1.username}" />
<property name="password" value="${activemq1.password}" />
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
//IBM MQ connection factory
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent" destroy-method="doStop">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="connectionFactory">
<bean class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy">
<constructor-arg>
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1" />
<property name="channel" value="${channel}" />
<property name="hostName" value="${hostname}" />
<property name="port" value="${port}" />
<property name="queueManager" value="${queueManager}" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
您可以使用用户 camel 额外组件 https://github.com/camel-extra/camel-extra/blob/master/components/camel-wmq/README.md to get messages from wmq without using the JMS wrapping and then send messages to ActiveMQ with custom camel component https://camel.apache.org/components/latest/activemq-component.html. See also a similar topic