如何让不同的端点在骆驼中使用不同的 Jms 组件?
how to let differents endpoints use differents JmsComponents in 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),我该怎么做?
当你定义
<bean id="jms2" class="org.apache.camel.component.jms.JmsComponent">...
</bean>
那么id "jms2"就是jms组件的名字。像上面一样为第二个 jms 组件给这个 id 一个不同的名称。
那么你可以这样引用它:
<to uri="jms2:incomingOrders2"/>
假设我有这个代码:
<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),我该怎么做?
当你定义
<bean id="jms2" class="org.apache.camel.component.jms.JmsComponent">...
</bean>
那么id "jms2"就是jms组件的名字。像上面一样为第二个 jms 组件给这个 id 一个不同的名称。
那么你可以这样引用它:
<to uri="jms2:incomingOrders2"/>