[jboss-user] [Messaging, JMS & JBossMQ] - Re: connection factory to remote queue

dlgrasse do-not-reply at jboss.com
Tue Jul 10 15:40:34 EDT 2007


After looking at the FAQ, Wiki, and other useless documentation, the answer was indeed found in the JNDI forum - in a post: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=112107.

Forget all those <tx-connection-factory> and JMSProvider tags in the links offered earlier.  (If you can get them to work for you, I'd love to see the exact configuration.  But as far as I'm concerned the examples are incomplete at best, and incorrect at worst.)  Here's how I got it to work for me.

Suppose you have JBoss server configured with a Queue running on it.  Call this ServerQ, and the queue name is Q.
Now you want to connect to it remotely.  If you were to do this from a stand-alone app, the answer is pretty simple - include 3 Properties values, which are easily provided via a jndi.properties file in the classpath.
  | java.naming.provider.url=jnp://<ServerQ>:1099
  | java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

And from your code you use ConnectionFactory jndi name "ConnectionFactory" and queue jndi ref "queue/Q".  I've used that technique several times successfully.

You would expect that if you were asking how to do that very thing from within JBoss the answer would be pretty much that very thing - bind a jndi name to a remote connection factory - and nothing else.  And in fact the solution that worked for me is exactly that.  Add the following tag to your jms/jms-ds.xml file.

    <mbean code='org.jboss.naming.ExternalContext'
  |            name='jboss.jndi:service=ExternalContext,jndiName=<some jndi ref>'
  |     >
  |         <attribute name='JndiName'><some jndi ref></attribute>
  |         <attribute name='Properties'>
  |             java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
  |             java.naming.factory.url.pkgs=org.jnp.interfaces
  |             java.naming.provider.url=<ServerQ>:1099
  |         </attribute>
  |         <depends>jboss:service=Naming</depends>
  |     </mbean>

Then from your code you reference the ConnectionFactory with jndi name "<some jndi ref>/ConnectionFactory" and the queue with jndi name "<some jndi ref>/queue/Q".


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4062657#4062657

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4062657

More information about the jboss-user mailing list