Jms-bridge to external AMQ not working . queue not found

Latest response

Hi,

I get NameNotFoundException when trying to connect to the queue at the external broker.

2020-07-07 02:40:17,944 WARN  [org.apache.activemq.artemis.jms.bridge] (Thread-117) AMQ342010: Failed to connect JMS Bridge my-jms-bridge: javax.naming.NameNotFoundException: CoordSend
        at org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:236)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at org.apache.activemq.artemis.jms.bridge.impl.JNDIFactorySupport.createObject(JNDIFactorySupport.java:46)
        at org.apache.activemq.artemis.jms.bridge.impl.JNDIDestinationFactory.createDestination(JNDIDestinationFactory.java:32)
        at org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl.setupJMSObjects(JMSBridgeImpl.java:1210)

standalone-full.xml

 <jms-bridge name="my-jms-bridge" module="org.apache.activemq.artemis" quality-of-service="AT_MOST_ONCE" failure-retry-interval="500" max-retries="1" max-batch-size="10" max-batch-time="100">
                <source connection-factory="ConnectionFactory" destination="jboss/jms/queue/CoordSend">
                    <source-context/>
                </source>
                <target connection-factory="ConnectionFactory" destination="CoordSend">
                    <target-context>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                    </target-context>
                </target>
            </jms-bridge>

Should I use some other module? Or should I use some other connection-factory?

Please advice.

Best regards,
Fredrik

Responses

I don't believe that "jboss/jms/queue/CoordSend" is a valid source definition.

Hi Tom,

That's the internal queue - the source destination. Not at the remote broker. The NameNotFound seems to be related to the target destination...

broker.xml

<acceptor name="artemis">tcp://0.0.0.0:61616?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1\
000;amqpLowCredits=300</acceptor>

 <addresses>
    <address name="CoordSend">
      <anycast>
        <queue name="CoordSend" />
      </anycast>
</address>

standalone-full.xml

<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">

 <address-setting name="jms.queue.CoordSend" dead-letter-address="jms.queue.CoordSend" expiry-address="jms.queue.ExpiryQueue" max-delivery-attempts="1" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-h\
istory-day-limit="10"/>

<jms-queue name="CoordSend" entries="java:jboss/jms/queue/CoordSend java:jboss/exported/jms/queue/CoordSend" durable="true"/>

<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>

 <jms-bridge name="my-jms-bridge" module="org.apache.activemq.artemis" quality-of-service="AT_MOST_ONCE" failure-retry-interval="500" max-retries="1" max-batch-size="10" max-batch-time="100">
                <source connection-factory="ConnectionFactory" destination="jboss/jms/queue/CoordSend">
                    <source-context/>
                </source>
                <target connection-factory="ConnectionFactory" destination="CoordSend">
                    <target-context>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                    </target-context>
                </target>
            </jms-bridge>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
  <bindings>

 <external-context name="java:global/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
                    <environment>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://127.0.0.1:61616"/>
                        <property name="queue.CoordSend" value="CoordSend"/>
                    </environment>
                </external-context>
                <lookup name="CoordSend" lookup="java:global/remoteContext/CoordSend"/>

If I change to java:/CoordSend I get following.

2020-07-07 14:24:05,473 WARN  [org.apache.activemq.artemis.jms.bridge] (Thread-114) AMQ342010: Failed to connect JMS Bridge my-jms-bridge: javax.naming.NamingException: scheme java not recognized
        at org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:222)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at org.apache.activemq.artemis.jms.bridge.impl.JNDIFactorySupport.createObject(JNDIFactorySupport.java:46)

Best regards, Fredrik

I don't believe that "jboss/jms/queue/CoordSend" is a correct definition of a local queue. Also you have "ConnectionFactory" for both source and target. That does not make sense.

No changes if I try to change that name (and it works outside the jms-bridge-scope)... :/

Jms-bridge according to the manual: https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.3/html-single/configuring_messaging/index#configuring_jms_bridges

  <jms-bridge name="my-jms-bridge" module="org.apache.activemq.artemis" max-batch-time="100" max-batch-size="10" max-retries="1" failure-retry-interval="500" quality-of-service="AT_MOST_ONCE">
    <source destination="jms/queue/InQueue" connection-factory="ConnectionFactory">
      <source-context/>
    </source>
    <target destination="jms/queue/OutQueue" connection-factory="jms/RemoteConnectionFactory">
      <target-context>
        <property name="java.naming.factory.initial" value="org.wildfly.naming.client.WildFlyInitialContextFactory"/>
        <property name="java.naming.provider.url" value="http-remoting://192.168.40.1:8080"/>
      </target-context>
    </target>
  </jms-bridge>

I have tried all of the connection-factories... but none works, different errors. If I try the netty connection factory and change the name.

<pooled-connection-factory name="activemq-ra-remote" entries="java:/RemoteJmsXA java:jboss/RemoteJmsXA" connectors="netty-remote-throughput" transaction="xa" user="admin" password="admin" max-pool-size="40"/>
            </server>

 <jms-bridge name="my-jms-bridge" module="org.apache.activemq.artemis" quality-of-service="AT_MOST_ONCE" failure-retry-interval="500" max-retries="1" max-batch-size="10" max-batch-time="100">
                <source connection-factory="ConnectionFactory" destination="jms/queue/CoordSend">
                    <source-context/>
                </source>
                <target connection-factory="RemoteJmsXA" destination="jms/queue/CoordSend">
                    <target-context>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                    </target-context>
                </target>
            </jms-bridge>

I get following:

WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jms.queue.CoordSend (missing) dependents: [service jboss.messaging-activemq.jms-bridge.my-jms-bridge]

Should I change my jms-queue definition?

If I rename the source queue to CoordError according to following.

 <jms-queue name="CoordError" entries="java:jboss/jms/queue/CoordError" durable="true"/>

 <jms-bridge name="my-jms-bridge" module="org.apache.activemq.artemis" quality-of-service="AT_MOST_ONCE" failure-retry-interval="500" max-retries="1" max-batch-size="10" max-batch-time="100">
                <source connection-factory="ConnectionFactory" destination="jboss/jms/queue/CoordError">
                    <source-context/>
                </source>
                <target connection-factory="RemoteJmsXA" destination="jms/queue/CoordSend">
                    <target-context>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                    </target-context>
                </target>
            </jms-bridge>

I still get the NameNotFound exception on the CoordSend name...

2020-07-07 16:34:56,129 WARN  [org.apache.activemq.artemis.jms.bridge] (ServerService Thread Pool -- 85) AMQ342010: Failed to connect JMS Bridge my-jms-bridge: javax.naming.NameNotFoundException: jms/queue/CoordSend

Any suggestions to limit the debugging?

Best regards, Fredrik

Hi Tom!

I got it to work!! :)

Added queue.CoordSend = CoordSend within the target-context property...

<property name="queue.CoordSend" value="CoordSend"/>

Also tried to reverse the target-source and it also works...

 <jms-bridge name="my-jms-bridge" module="org.apache.activemq.artemis" quality-of-service="AT_MOST_ONCE" failure-retry-interval="500" max-retries="1" max-batch-size="10" max-batch-time="100">
                <source connection-factory="ConnectionFactory" destination="CoordSend">
                    <source-context>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://localhost:61616"/>
                        <property name="queue.CoordSend" value="CoordSend"/>
                    </source-context>
                </source>
                <target connection-factory="ConnectionFactory" destination="jboss/jms/queue/CoordError">
                    <target-context/>
                </target>
            </jms-bridge>

&Freddan

Are you sure it works? Not sure why would you want to have a jms bridge if you can use RA. Here's a working JMS bridge between TIBCO and EAP

<jms-bridge name="pullBridge" module="org.jboss.genericjms.provider" quality-of-service="ONCE_AND_ONLY_ONCE" failure-retry-interval="60000" max-retries="15" max-batch-size="1" max-batch-time="100">
                <source connection-factory="jms/cf/XAQueueConnectionFactory" destination="jms/queue/sourceQueue" user="${tibco.user}" password="${tibco.password}">
                    <source-context>
                        <property name="java.naming.factory.initial" value="com.tibco.tibjms.naming.TibjmsInitialContextFactory"/>
                        <property name="java.naming.factory.url.pkgs" value="com.tibco.tibjms.naming"/>
                        <property name="java.naming.provider.url" value="tcp://${tibco.host}:${tibco.port}"/>
                        <property name="java.naming.security.principal" value="${tibco.user}"/>
                        <property name="java.naming.security.credentials" value="${tibco.password}"/>
                        <property name="org.jboss.as.naming.lookup.by.string" value="true"/>
                    </source-context>
                </source>
                <target connection-factory="java:/BridgeConnectionFactory" destination="java:/jms/queue/targetQueue"/>
            </jms-bridge>
            <jms-bridge name="pushBridge" module="org.jboss.genericjms.provider" quality-of-service="ONCE_AND_ONLY_ONCE" failure-retry-interval="60000" max-retries="-1" max-batch-size="1" max-batch-time="100">
                <source connection-factory="java:/BridgeConnectionFactory" destination="java:/jms/queue/sourceQueue"/>
                <target connection-factory="jms/cf/XAQueueConnectionFactory" destination="jms/queue/targetQueue" user="${tibco.user}" password="${tibco.password}">
                    <target-context>
                        <property name="java.naming.factory.initial" value="com.tibco.tibjms.naming.TibjmsInitialContextFactory"/>
                        <property name="java.naming.factory.url.pkgs" value="com.tibco.tibjms.naming"/>
                        <property name="java.naming.provider.url" value="tcp://${tibco.host}:${tibco.port}"/>
                        <property name="java.naming.security.principal" value="${tibco.user}"/>
                        <property name="java.naming.security.credentials" value="${tibco.password}"/>
                        <property name="org.jboss.as.naming.lookup.by.string" value="true"/>
                    </target-context>
                </target>
 </jms-bridge>

Yes, I'm sure. Have tested the complete chain, stopping and starting jboss and forward it to different destinations.

Aaaa, nice. Thanks, really good example. Haven't tried the org.jboss.genericjms.provider... cool.

The purpose is that we use the AMQ broker at our FUSE server. Then that side of the integration application can work "independent". The MDB:s need to be able to work also kind of "independent" so we want local queues and then we use the bridges to handle offline/online and patches that can occure. And we don't need to have an own broker at the jboss side...

&Fredrik

Thanks! :)