5 Replies Latest reply on Jun 14, 2011 9:31 AM by Geert Pante

    Bridge ActiveMQ to HornetQ

    Mark Stuff Newbie

      I am working on bridging ActiveMQ and HornetQ.  I have been unable to find sufficient resources that demonstrate how this can be done.  The closest I have gotten is to bridge via Camel, but have not gotten that to work either.

       

      Could someone please provide either instructions or a link to information on how to accomplish this task.

       

      Thanks

        • 1. Re: Bridge ActiveMQ to HornetQ
          Clebert Suconic Master

          We have a JMS Bridge.. look at the manual...

           

          basically you just need ActiveMQ client Libraries and HornetQ Client libraries on both sides.

           

           

           

          I'm not sure but I believe ActiveMQ has a JMS Bridge also.. so they should be able to bridge from their side also.

           

           

          Basically you can chose from what side you want to bridge from.

          1 of 1 people found this helpful
          • 2. Re: Bridge ActiveMQ to HornetQ
            Mark Stuff Newbie

            I read through the manual.  Maybe the answer I am looking for is not jumping out at me, but I don't see where there is information on configuring a connection to ActiveMQ.  It appears that the easiest way to do this is with Camel.  I have Camel all configured except for the connection factory for HornetQ.  Any ideas on what I would use for this?  I believe it should be something like:

             

            <bean class="org....ConnectionFactory" id="hornetMQConnectionFactory">

            <property name="URI" value="...."/>

            </bean>

             

            Is it possible to define a HornetQ connection factory from within Spring?

            • 3. Re: Bridge ActiveMQ to HornetQ
              Clebert Suconic Master

              Look at the example at the documentation:

               

              http://docs.jboss.org/hornetq/2.2.2.Final/user-manual/en/html/jms-bridge.html

               

               

               

              Define the a JNDIActiveMQ with the JNDI properties for ActiveMQ

              Define another JNDIHOrnetQ with the JNDI properties for HornetQ

               

               

              Create the proper FactoriesFactories (that will do the lookup using the JNDI)

               

               

              All you will need besides this is to have the proper JARs in place.

              1 of 1 people found this helpful
              • 4. Re: Bridge ActiveMQ to HornetQ
                Mark Stuff Newbie

                Based on the example/jms/jms-bridge example honetq-beans.xml file, I have modified the file with these changes:

                 

                        <bean name="TargetCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">

                           <constructor>

                               <parameter>

                                   <inject bean="ActiveMQJNDI" />

                               </parameter>

                               <parameter>/target/ConnectionFactory</parameter>

                           </constructor> 

                       </bean>

                 

                 

                      <bean name="ActiveMQJNDI" class="java.util.Hashtable">

                         <constructor class="java.util.Map">

                            <map class="java.util.Hashtable" keyClass="java.lang.String"

                                                             valueClass="java.lang.String">

                               <entry>

                                  <key>java.naming.factory.initial</key>

                                  <value>org.apache.activemq.jndi.ActiveMQInitialContextFactory</value>

                               </entry>

                                <entry>

                                  <key>java.naming.provider.url</key>

                                  <value>tcp://127.0.0.1:61616</value>

                               </entry>

                                <entry>

                                  <key>queue.MyQueue</key>

                                  <value>hornetq.bridge.mwqueue</value>

                               </entry>

                            </map>

                         </constructor>

                      </bean>

                 

                 

                What does "Create the proper FactoriesFactories (that will do the lookup using the JNDI)" mean?  Where can I find information on this? 

                 

                Currently with this setup I am getting the following stack trace:

                 

                javax.naming.NameNotFoundException: source not bound

                        at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)

                        at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)

                        at org.jnp.server.NamingServer.getObject(NamingServer.java:785)

                        at org.jnp.server.NamingServer.lookup(NamingServer.java:396)

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                        at java.lang.reflect.Method.invoke(Unknown Source)

                        at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

                        at sun.rmi.transport.Transport$1.run(Unknown Source)

                        at java.security.AccessController.doPrivileged(Native Method)

                        at sun.rmi.transport.Transport.serviceCall(Unknown Source)

                        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

                        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)

                        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                        at java.lang.Thread.run(Unknown Source)

                        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)

                        at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

                        at sun.rmi.server.UnicastRef.invoke(Unknown Source)

                        at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)

                        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)

                        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

                        at javax.naming.InitialContext.lookup(Unknown Source)

                        at org.hornetq.jms.bridge.impl.JNDIFactorySupport.createObject(JNDIFactorySupport.java:58)

                        at org.hornetq.jms.bridge.impl.JNDIDestinationFactory.createDestination(JNDIDestinationFactory.java:40)

                        at org.hornetq.jms.bridge.impl.JMSBridgeImpl.setupJMSObjects(JMSBridgeImpl.java:1082)

                        at org.hornetq.jms.bridge.impl.JMSBridgeImpl.start(JMSBridgeImpl.java:345)

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                        at java.lang.reflect.Method.invoke(Unknown Source)

                        at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

                        at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

                        at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)

                        at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)

                        at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)

                        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)

                        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)

                        at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)

                        at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)

                        at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)

                        at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:319)

                        at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:297)

                        at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130)

                        at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96)

                        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:236)

                        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:206)

                        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:155)

                        at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83)

                        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:116)

                        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.main(HornetQBootstrapServer.java:73)

                [main] 14:40:42,423 WARNING [org.hornetq.jms.bridge.impl.JMSBridgeImpl]  Failed to start bridge

                • 5. Re: Bridge ActiveMQ to HornetQ
                  Geert Pante Newbie

                  The JMS Bridge indeed lacks some detailed documentation. I had to read to the source code, too, to figure it all out.

                  http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.hornetq/hornetq-jms/2.2.2.Final/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java?av=f

                   

                  In the jms-bridge example, the source ConnectionFactory is bound to JNDI under the name "/source/ConnectionFactory", and the Destination under "/source/topic". This should be replaced with your HornetQ configuration. See your hornetq-jms.xml or find it in e.g. JNDIView via JMX Console.

                   

                  For the target ConnectionFactory and Destination holds the same: you should use the ActiveMQ's JNDI name of the ConnectionFactory and the Destination to replace /target/ConnectionFactory and /target/queue in the JMSBridge configuration.

                   

                  Good luck, Geert.