如何让不同端点在驼峰中使用不同的JmsComponents?

时间:2015-07-04 20:47:13

标签: java spring jms apache-camel

假设我有这段代码:

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
 <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
 <property name="connectionFactory">
 <bean class="org.apache.activemq.ActiveMQConnectionFactory">
 <property name="brokerURL" value="vm://localhost" />
 </bean>
 </property>
 </bean>
</beans>

<routeContext id="ftpToJms1" xmlns="http://camel.apache.org/schema/spring">
 <route>
 <from uri="ftp://rider.com/orders?username=rider&password=secret"/>
 <to uri="jms:incomingOrders1"/>
 </route>
</routeContext>
<routeContext id="ftpToJms2" xmlns="http://camel.apache.org/schema/spring">
 <route>
 <from uri="ftp://rider.com/orders?username=rider&password=secret"/>
 <to uri="jms:incomingOrders2"/>
 </route>
</routeContext>

<camelContext xmlns="http://camel.apache.org/schema/spring">
 <routeContextRef ref="ftpToJms1"/>
 <routeContextRef ref="ftpToJms2"/>
</camelContext>

我希望ftpToJms1和ftpToJms2将使用不同的JmsComponents(我想再添加一个JmsComponen),我该怎么办?

1 个答案:

答案 0 :(得分:1)

定义时

<bean id="jms2" class="org.apache.camel.component.jms.JmsComponent">...
</bean>

然后id“jms2”是jms组件的名称。只需为这个id赋予第二个jms组件的不同名称,如上所述。

然后你可以参考它:

<to uri="jms2:incomingOrders2"/>