2 Replies Latest reply on Mar 2, 2017 12:52 PM by Sai Pabbathi

    How do you use @Resource to connect to remote JMS queues

    Kristjan Gudbjornsson Newbie

      Hi, I am looking for a way to inject remote queues into my code in a similar way as is done with connection factories.


      My environment:

      JBoss 5.1 EAP in two clusters

      - A messaging cluster that runs JBoss Messaging 1.4.7.GA

      - An application cluster, that connects to the remote JMS on the messaging cluster. JBoss Messaging has been removed in the application cluster, and a remote JMS provider added.


      The problem is the mapped name in the queue injection, a remote jndi lookup is needed to inject the queue.

      My resource injection looks like this:



      Destination jmdest;




      We have four different environments, Development, Test, Staging and Production.  And that requires different host:port configuration for each environment, because each environment has its own messaging cluster.

      Is there a way to do the queue lookup in a similar way to the connection factory lookup?  How do you inject remote resources in your code?


      Here is the application cluster JMS configuration


      <mbean code="org.jboss.jms.jndi.JMSProviderLoader"


          <attribute name="ProviderName">RemoteJMSProvider</attribute>

          <attribute name="ProviderAdapterClass">



          <!-- The combined connection factory -->

          <attribute name="FactoryRef">XAConnectionFactory</attribute>

          <!-- The queue connection factory -->

          <attribute name="QueueFactoryRef">XAConnectionFactory</attribute>

          <!-- The topic factory -->

          <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>

          <!-- Access JMS via HAJNDI -->

          <attribute name="Properties">













      <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->






          <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>

          <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/RemoteJMSProvider</config-property>


          <config-property name="UserName" type="java.lang.String">guest</config-property>

          <config-property name="Password" type="java.lang.String">guest</config-property>