7 Replies Latest reply on Apr 15, 2014 2:02 PM by cmartin39

    JMS Bridge only working one direction

    cmartin39

      I have a jms bridge set up this way:

      <jms-bridge name="glassfishToJbossBridge" module="org.glassfish">

                      <source>

                          <connection-factory name="jmsConnectionFactory"/>

                          <destination name="jms/downlinkQueue"/>

                          <context>

                              <property key="java.naming.factory.initial" value="com.sun.enterprise.naming.SerialInitContextFactory"/>

                              <property key="java.naming.factory.url.pkgs" value="com.sun.enterprise.naming"/>

                              <property key="java.naming.factory.state" value="com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"/>

                              <property key="java.naming.provider.url" value="localhost:3700"/>

                          </context>

                      </source>

                      <target>

                          <connection-factory name="java:/jmsConnectionFactory"/>

                          <destination name="jms/downlinkQueue"/>

                          <context>

                              <property key="java.naming.factory.initial" value="org.jboss.as.naming.InitialContextFactory"/>

                              <property key="java.naming.factory.url.pkgs" value="com.sun.enterprise.naming"/>

                              <property key="java.naming.factory.state" value="com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"/>

                              <property key="java.naming.provider.url" value="localhost:4447"/>

                          </context>

                      </target>

                      <quality-of-service>AT_MOST_ONCE</quality-of-service>

                      <failure-retry-interval>500</failure-retry-interval>

                      <max-retries>1</max-retries>

                      <max-batch-size>500</max-batch-size>

                      <max-batch-time>500</max-batch-time>

                      <add-messageID-in-header>true</add-messageID-in-header>

                  </jms-bridge>

       

      This is works fine going from openMq to wildfly

       

      but when i try the other direction(wildfly->openMq)

      i get exceptions. The bridge looks like


      <jms-bridge name="jbossToGlassfishBridge" module="org.glassfish">

                      <target>

                          <connection-factory name="jmsConnectionFactory"/>

                          <destination name="jms/downlinkQueue"/>

                          <context>

                              <property key="java.naming.factory.initial" value="com.sun.enterprise.naming.SerialInitContextFactory"/>

                              <property key="java.naming.factory.url.pkgs" value="com.sun.enterprise.naming"/>

                              <property key="java.naming.factory.state" value="com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"/>

                              <property key="java.naming.provider.url" value="localhost:3700"/>

                          </context>

                      </target>

                      <source>

                          <connection-factory name="java:/jmsConnectionFactory"/>

                          <destination name="jms/downlinkQueue"/>

                          <context>

                              <property key="java.naming.factory.initial" value="org.jboss.as.naming.InitialContextFactory"/>

                              <property key="java.naming.factory.url.pkgs" value="com.sun.enterprise.naming"/>

                              <property key="java.naming.factory.state" value="com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"/>

                              <property key="java.naming.provider.url" value="localhost:4447"/>

                          </context>

                      </source>

                      <quality-of-service>AT_MOST_ONCE</quality-of-service>

                      <failure-retry-interval>500</failure-retry-interval>

                      <max-retries>1</max-retries>

                      <max-batch-size>500</max-batch-size>

                      <max-batch-time>500</max-batch-time>

                      <add-messageID-in-header>true</add-messageID-in-header>

                  </jms-bridge>

       

      The exception is:

       

      2014-04-09 12:27:58,219 WARN  [org.hornetq.jms.server] (ServerService Thread Pool -- 59) HQ122010: Failed to connect JMS Bridge: javax.naming.NameNotFoundException: jms/downlinkQueue -- service jboss.naming.context.java.jms.downlinkQueue

          at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)

          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)

          at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:233)

          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:188)

          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)

          at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

          at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

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

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

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

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

          at org.jboss.as.messaging.jms.bridge.JMSBridgeService.startBridge(JMSBridgeService.java:105)

          at org.jboss.as.messaging.jms.bridge.JMSBridgeService$1.run(JMSBridgeService.java:79)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]

          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

          at org.jboss.threads.JBossThread.run(JBossThread.java:122)

        • 1. Re: JMS Bridge only working one direction
          jbertram

          Try completely removing the <context> for the source/target when it's pointing to the local server.

          • 2. Re: JMS Bridge only working one direction
            cmartin39

            When i do that i get this error:

             

            HQ122010: Failed to connect JMS Bridge: javax.naming.NamingException: Lookup failed for 'java:/jmsConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.ldap.version=3, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ]

                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518) [glassfish-embedded-all-3.1.1.jar:]

                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) [glassfish-embedded-all-3.1.1.jar:]

                at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

                at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

                at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

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

                at org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory.createConnectionFactory(JNDIConnectionFactoryFactory.java:37)

                at org.hornetq.jms.bridge.impl.JMSBridgeImpl.createConnection(JMSBridgeImpl.java:1080)

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

                at org.hornetq.jms.bridge.impl.JMSBridgeImpl.setupJMSObjectsWithRetry(JMSBridgeImpl.java:1457)

                at org.hornetq.jms.bridge.impl.JMSBridgeImpl.access$2000(JMSBridgeImpl.java:76)

                at org.hornetq.jms.bridge.impl.JMSBridgeImpl$FailureHandler.run(JMSBridgeImpl.java:2046)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]

                at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

            Caused by: javax.naming.NamingException: Invocation exception: Got null ComponentInvocation

                at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getComponentId(GlassfishNamingManagerImpl.java:873) [glassfish-embedded-all-3.1.1.jar:]

                at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:742) [glassfish-embedded-all-3.1.1.jar:]

                at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:180) [glassfish-embedded-all-3.1.1.jar:]

                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498) [glassfish-embedded-all-3.1.1.jar:]

                ... 14 more

             

            it looks like it is trying to connect to openmq for the local jms also.

             

            Here is my bridge setting

             

            <jms-bridge name="jbossToGlassfishBridge" module="org.glassfish">

                            <target>

                                <connection-factory name="jmsConnectionFactory"/>

                                <destination name="jms/gstr/lcs/downlinkQueue"/>

                                <context>

                                    <property key="java.naming.factory.initial" value="com.sun.enterprise.naming.SerialInitContextFactory"/>

                                    <property key="java.naming.factory.url.pkgs" value="com.sun.enterprise.naming"/>

                                    <property key="java.naming.factory.state" value="com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"/>

                                    <property key="java.naming.provider.url" value="localhost:3700"/>

                                </context>

                            </target>

                            <source>

                                <connection-factory name="java:/jmsConnectionFactory"/>

                                <destination name="jms/gstr/lcs/downlinkQueue"/>

                            </source>

                            <quality-of-service>AT_MOST_ONCE</quality-of-service>

                            <failure-retry-interval>500</failure-retry-interval>

                            <max-retries>1</max-retries>

                            <max-batch-size>500</max-batch-size>

                            <max-batch-time>500</max-batch-time>

                            <add-messageID-in-header>true</add-messageID-in-header>

                        </jms-bridge>

            • 3. Re: JMS Bridge only working one direction
              jmesnil

              could you show the content of your org.glassfish and its module.xml definition, please?

              • 4. Re: JMS Bridge only working one direction
                cmartin39

                <module xmlns="urn:jboss:module:1.0" name="org.glassfish"> 

                  <resources> 

                    <resource-root path="glassfish-embedded-all-3.1.1.jar"/>

                  </resources> 

                  <dependencies> 

                  <system export="true">

                    <paths>

                        <path name="sun/corba"/>

                       

                    </paths>

                  </system>

                        <!-- add the dependencies required by JMS Bridge code                -->

                       <module name="javax.api" />

                       <module name="javax.jms.api" />

                       <module name="javax.transaction.api"/>

                       <module name="javax.resource.api"/>

                       <module name="javax.rmi.api"/>

                       <module name="org.omg.api"/>

                       <module name="sun.jdk"/>

                  </dependencies> 

                </module>

                 

                the only thing in my org.glassfish is glassfish-embedded-all-3.1.1.jar

                • 5. Re: JMS Bridge only working one direction
                  jmesnil

                  I was able to create a bridge from WildFly to GlassFish but it's more complicate than it should.

                   

                  First, you should use this JMS bridge definition:

                   

                  <jms-bridge name="wildfly2glassfish" module="org.glassfish">

                    <source>

                      <connection-factory name="java:/ConnectionFactory"/>

                      <destination name="jms/wildflyQueue"/>

                      <context>

                        <property key="java.naming.factory.initial" value="org.jboss.as.naming.InitialContextFactory"/>

                      </context>

                    </source>

                    <target>

                      <connection-factory name="glassfishCF"/>

                      <destination name="jms/glassfishQueue"/>

                      <context>

                        <property key="java.naming.factory.initial" value="com.sun.enterprise.naming.SerialInitContextFactory"/>

                      </context>

                    </target>

                    <quality-of-service>AT_MOST_ONCE</quality-of-service>

                    <failure-retry-interval>2000</failure-retry-interval>

                    <max-retries>10</max-retries>

                    <max-batch-size>500</max-batch-size>

                    <max-batch-time>500</max-batch-time>

                    <add-messageID-in-header>true</add-messageID-in-header>

                  </jms-bridge>

                   

                  The main change compared to yours is that I let the JMS bridge retries to connect 10 times with a 2000ms retry interval.

                   

                  The main issue is that GlassFish "hi-jack" JNDI by specifying its own jndi.properties. That means that in the JMS Bridge, calling new InitialContext() will create a context for the "remote" glass fish and no longer for the local wildfly.

                  This is why we have to specify the <context> also for the local source objects. However since we can no longer distinguish local from remote resource, the JMS bridge will be started asap and will not wait for the local wildfly queue to be deployed. That's why we have to retry the JMS bridge so that it can lookup the local wildfly queue at the next retry:

                   

                  14:21:53,667 WARN  [org.hornetq.jms.server] (ServerService Thread Pool -- 57) HQ122010: Failed to connect JMS Bridge: javax.naming.NameNotFoundException: jms/wildflyQueue -- service jboss.naming.context.java.jms.wildflyQueue

                          at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)

                          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)

                          at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:233)

                          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:188)

                          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)

                          at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

                          at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]

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

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

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

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

                          at org.jboss.as.messaging.jms.bridge.JMSBridgeService.startBridge(JMSBridgeService.java:105)

                          at org.jboss.as.messaging.jms.bridge.JMSBridgeService$1.run(JMSBridgeService.java:79)

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]

                          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

                          at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                  => JMS bridge is started before the local wildfly queue

                  ...

                  14:21:53,673 WARN  [org.hornetq.jms.server] (ServerService Thread Pool -- 57) HQ122001: Failed to start JMS Bridge

                  14:21:53,677 INFO  [org.jboss.messaging] (ServerService Thread Pool -- 57) JBAS011610: Started JMS Bridge wildfly2glassfish

                  14:21:53,677 WARN  [org.hornetq.jms.server] (pool-3-thread-1) HQ122004: JMS Bridge Will retry after a pause of 2,000 ms

                   

                  ...


                  14:21:54,255 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 59) HQ221003: trying to deploy queue jms.queue.wildflyQueue

                  14:21:54,256 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 59) JBAS011601: Bound messaging object to jndi name java:/jms/wildflyQueue

                  => local wildfly queue is deployed

                  ...

                  14:21:58,089 INFO  [javax.resourceadapter.mqjmsra.lifecycle] (pool-3-thread-1) MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version:  5.0  (Build 14-e) Compile:  April 12 2013 0104

                  14:21:58,089 INFO  [javax.resourceadapter.mqjmsra.lifecycle] (pool-3-thread-1) MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is REMOTE, connection mode is TCP

                  14:21:58,098 INFO  [javax.resourceadapter.mqjmsra.lifecycle] (pool-3-thread-1) MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:REMOTE

                  14:21:58,455 INFO  [org.hornetq.jms.server] (pool-3-thread-1) HQ121002: Succeeded in connecting to servers

                  => the bridge is connected successfully.

                   

                  This is more complex than it should and this could be simplified if GlashFish was not hijacking the JNDI context when it is embedded...

                  I try to remove the jndi.properties from their embedded jar and add pass the props in the <context> but that does not work as their naming code instantiates new InitialContext() and expect to have magically it using their env (instead of the embedding code)...

                  • 6. Re: JMS Bridge only working one direction
                    jbertram

                    Nice work, Jeff.  This makes perfect sense of what was quite puzzling behavior.

                    • 7. Re: JMS Bridge only working one direction
                      cmartin39

                      Thanks. This solves my issue