What you are trying to do is implement a bridge pattern. Now, although JMS bridges are typically designed to provide a mechanism between JMS message providers, an integration pattern can also be used for wired protocols.
So, if you are trying to send messages between ActiveMQ - RabbitMQ here, then there are potential options:
1) ActiveMQ support - Defacto JMS, AMQP, STOMP 2) RabbitMQ support - Defacto STOMP, AMQP is also supported along with other popular wired protocols such as MQTT
So, when it comes to bridges:
a) [1] JMS - [2] STOMP (or) AMQP b) [1] AMQP (or) STOMP - [2] AMQP (or) STOMP
In the case of the 1st and 2nd bridge options, the easiest way to implement this is to use the Apache QPID client.
Alternatively, for most reliable configurations, it is better to use it as a Spring Integration Channel or a camel route.
Here's a snippet of how to do this using Spring Integration:
<beans:bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> <beans:property name="environment"> <beans:props> <beans:prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</beans:prop> <beans:prop key="java.naming.provider.url">jnp://localhost:1099</beans:prop> <beans:prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</beans:prop> </beans:props> </beans:property> </beans:bean> <beans:bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <beans:property name="jndiTemplate"> <beans:ref bean="jndiTemplate"/> </beans:property> <beans:property name="jndiName"> <beans:value>ConnectionFactory</beans:value> </beans:property> </beans:bean> <int-jms:message-driven-channel-adapter connection-factory="jmsQueueConnectionFactory" destination-name="myJmsQueue" channel="rabbitChannel"/> <channel id="rabbitChannel"/> <int-amqp:outbound-channel-adapter channel="rabbitChannel" exchange-name="fromJmsExchange" amqp-template="rabbitTemplate"/> <rabbit:template id="rabbitTemplate" connection-factory="cf"/> <rabbit:connection-factory id="cf" host="localhost"/> <rabbit:admin connection-factory="cf"/> <rabbit:queue name="fromJMS"/> <rabbit:direct-exchange name="fromJmsExchange"> <rabbit:bindings> <rabbit:binding queue="fromJMS"/> </rabbit:bindings> </rabbit:direct-exchange>
Article source: http://integrationsphere.blogspot.co.uk/2012/03/bridging-between-jms-and-rabbitmq-amqp.html
source share