Reputation: 476
I'm having a hard time getting this to work. Here is my setup
Server1 - JBoss AS 7.1 - Bean1, Bean2 (stateful session beans)
Server2 - JBoss AS 7.1 - HornetQ, MDB1
The idea is to send a message to HornetQ on Server2 from Bean1. I just can't believe it is this difficult. I have tried everything under the sun, but it just doesn't work. The fundamental issue I see is that the JNDI lookup that I'm doing in Bean1 is pointing to Server1 instead of Server2. And hence I get a queue not found exception when I do a look up for the queue. I've also tried starting AS with -b option pointing to Server2. How do I do a JNDI lookup of Server2/HornetQ from Server1/Bean1?
I'm, however, able to send a message to the same queue from a standalone console application (that has nothing to do with JBoss AS 7 at all). The JNDI lookup works perfectly fine when I do it from a console application.
TIA
Upvotes: 1
Views: 880
Reputation: 5383
Option 1:
You have to lookup from a remote JNDI.
I'm not sure ATM how to specifying jndiProps.setProperty(Context.PROVIDER_URL, "127.0.0.1:4447"); in one of the JNDI Properties.
Option 2:
you could create a local Pooled connection factory bound to the remote server:
First specify a connector:
<connectors>
<netty-connector name="remote-jms" socket-binding="messaging-remote"/>
...
</connectors>
And also specify the socket binding:
<socket-binding-group ....>
....
<outbound-socket-binding name="remote-jms">
<remote-destination host="other-hos" port="5445"/>
</outbound-socket-binding>
</socket-binding-group>
And then specify the pooled connection factory that will be connected remotely.
<pooled-connection-factory name="ConnectionFactory1">
<user>jmsuser</user>
<password>jmspassword</password>
<connectors>
<connector-ref connector-name="remote-jms" />
</connectors>
<entries>
<entry name="java:/ConnectionFactory1" />
</entries>
</pooled-connection-factory>
Option 3:
Create the connection factory without using JNDI. Notice that you will perform a network call every time you connect. the best would be to pool a connection:
http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/using-jms.html#d0e1361
Upvotes: 1