[jboss-user] [JBoss Messaging] - How do you use @Resource to connect to remote JMS queues

Kristjan Gudbjornsson do-not-reply at jboss.com
Wed Jun 1 06:29:05 EDT 2011


Kristjan Gudbjornsson [http://community.jboss.org/people/kristjan.steinar] created the discussion

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

To view the discussion, visit: http://community.jboss.org/message/608087#608087

--------------------------------------------------------------
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:

@Resource(mappedName="jnp://localhost:1199/jms/jb.itu.tes.jms.test.queue.b")
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"
     name="jboss.messaging:service=JMSProviderLoader,name=RemoteJMSProvider">
    <attribute name="ProviderName">RemoteJMSProvider</attribute>
    <attribute name="ProviderAdapterClass">
      org.jboss.jms.jndi.JNDIProviderAdapter
    </attribute>
    <!-- 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">
       java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
       java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
       jnp.disableDiscovery=false
       jnp.partitionName=DocsPartitionCluster
       jnp.discoveryGroup=239.255.100.101
       jnp.discoveryPort=1102
       jnp.discoveryTTL=16
       jnp.discoveryTimeout=5000
       jnp.maxRetries=1
    </attribute>
</mbean>

<!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
<tx-connection-factory>
    <jndi-name>RemoteJmsXA</jndi-name>
    <xa-transaction/>
    <rar-name>jms-ra.rar</rar-name>
    <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
    <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>
    <max-pool-size>20</max-pool-size>
    <config-property name="UserName" type="java.lang.String">guest</config-property>
    <config-property name="Password" type="java.lang.String">guest</config-property>
    <security-domain-and-application>RemoteJmsXARealm</security-domain-and-application>
</tx-connection-factory>
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/608087#608087]

Start a new discussion in JBoss Messaging at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110601/0ea6ef74/attachment-0001.html 


More information about the jboss-user mailing list