我试图确定使用Apache和Spring将来自两个hornetq实例的消息流组合到一个处理的单一流中的最佳方法。这本质上是与骆驼接收者名单模式相反的,但我需要的不是一对多,而是多对一。一个想法是使用直接组件实现此功能:
<?xml version="1.0" encoding="UTF-8"/>
<beans xmlns="..."
xmlns="...">
<!-- JMS Connection 1 -->
<bean id="jndiTemplate1" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
...Connection 1 Specific Information...
</props>
</property>
</bean>
<bean id="jmsTopicConnectionFactory1"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate1"/>
</property>
<property name="jndiName">
<value>java:jms/RemoteConnectionFactory</value>
</property>
</bean>
<bean id="jms1" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsTopicConnectionFactory1"/>
</bean>
<!-- JMS Connection 2 -->
<bean id="jndiTemplate2" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
...Connection 2 Specific Information...
</props>
</property>
</bean>
<bean id="jmsTopicConnectionFactory2"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate2"/>
</property>
<property name="jndiName">
<value>java:jms/RemoteConnectionFactory</value>
</property>
</bean>
<bean id="jms2" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsTopicConnectionFactory2"/>
</bean>
<!-- Camel route many to 1 using direct component -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="hornetQ_broker_1">
<from uri="jms1:topic:testTopic1">
<to uri="direct:process_message">
</route>
<route id="hornetQ_broker_2">
<from uri="jms2:topic:testTopic2">
<to uri="direct:process_message">
</route>
<route id="message_processor">
<from uri="direct:process_message">
<log message="message_processor received message">
</route>
</camelContext>
</beans>问题:当需要多个->1集成模式时,是否建议采用上述方法?如果存在多个Apache解决方案,那么每种方法对性能的主要影响是什么?
运行时环境:
备注:
发布于 2013-12-16 18:34:34
我认为你的方法对你的方案是有效的。但是,如果您在不同的JVM中运行,则可能不需要使用直接组件。
内部队列有不同的组件:直接、直接- VM、SEDA、VM、Disruptor.但我相信,如果您在JVM中运行(如果您只是在同一个CamelContext中运行),那么它们都是这样的。欲了解更多信息:如何比较直接、事件、seda和vm端点?
如果要跨不同的CamelContexts使用不同的JVM,则需要使用不同的组件。
https://stackoverflow.com/questions/20616368
复制相似问题