-
1. Re: Using JNDIProviderAdapter from client (MDB) code?
ewestland Aug 19, 2006 9:14 AM (in response to ewestland)"That was easy!!!" - sigh...
InitialContext localCtx = new InitialContext(); JNDIProviderAdapter jmsProvider = (JNDIProviderAdapter) localCtx.lookup("java:/RemoteJMSProvider"); Properties jmsProviderProps = jmsProvider.getProperties(); InitialContext remoteCtx = new InitialContext(jmsProviderProps); Destination topic = (Destination) remoteCtx.lookup("queue/test");
Note: You will need to include jboss.jar in build path.
Cheers,
Erik -
2. Re: Using JNDIProviderAdapter from client (MDB) code?
genman Aug 20, 2006 2:10 AM (in response to ewestland)
For inbound, define your configuration in standardjboss.xml and then in jboss.xml:<message-driven> <ejb-name>RouterMDB</ejb-name> <destination-jndi-name>...</destination-jndi-name> <configuration-name>Remote Message Driven Bean</configuration-name>
It's better to use a -ds.xml file (JCA) connection to your provider outbound.
Then you simply do:ConnectionFactory cf = new InitialContext().lookup("java:/RemoteJmsXA"); Connection c = cf.createQueueConnection(); try { } finally { c.close(); }
-
3. Re: Using JNDIProviderAdapter from client (MDB) code?
ewestland Aug 21, 2006 12:08 AM (in response to ewestland)Thanks for the tip...
I am pretty wiped out now, so forgive me, but I don't quite get your solution.
My objective is indeed to use "a -ds.xml file (JCA) connection to your provider outbound", but my initial problem was getting access to the destinations on the remote JMS provider. My JBoss-specific (hokey?) solution does that.
I like that your solution looks portable, but it appears to be missing some of the extra sauce. My issue is that I am unclear how to lookup the remote destination (i.e. "queue/test") etc; assuming remote provider defined as "RemoteJmsXA" (i.e. ./deploy/jms/remotejmsxa-ds.xml).
If you could extend your example a bit to include creating a "MessageProducer" to a remote queue it would be helpful.
Standard example client code:InitialContext ctx = new InitialContext(); Destination topic = (Destination) ctx.lookup("queue/test"); ConnectionFactory factory = (ConnectionFactory)ctx.lookup("UIL2ConnectionFactory"); Connection connection = factory.createConnection(); Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageProducer publisher = session.createProducer(topic); ...
Cheers,
Erik