This content has been marked as final. Show 2 replies
Are the two GlassFish instances configured to be part of the same GlassFish cluster? If so then you don't need to do anything. MyQueue will work as a single queue for both instances.
If the two GlassFish instances are NOT clustered then you have two separate queues, both with the JNDI name MyQueue. In this case you need to either
1. Configure the sending application to send messages to the other instance
2. Configure the MDB to receive messages from the other instance
(obviously you must do one or the other, not both!).
To define which instance a MDB receives messages from, set the activation config property connectionURL to point to the other instance. This will have the form mq://hostname:jmsport
To define which instance an application sends messages to, set the connection factory property addressList to point to the other instance. Again, this will have the form mq://hostname:jmsport
Don't forget that when you create the Queue object with JNDI name jms/MyQueue you need to define a property "Name" and set it to the actual name of the queue.
The first thing I would like to suggest is, we never/can't send message directly to MDB. We always send/receive message(s) to/from the destination. In case of MDB, the application server register the MDB as message listener against particular destination, and invoked the onMessage() method when message arrives on particular destination.
If I am not wrong, what you want to achieve is asynchronous communication between two applications deployed in two different machine. In your case, you want your one application works as message producer and other act as an message consumer, and both are deployed in different machine.
In this situations, you only need to configure the JMS administration object, connection factories and destinations, on one Application server and configure other application server to use those configuration using JMS resource adapter. you can well achieve this by configuring the JMS Resource Adapter. you need to check the Glassfish documentation.
If you don't want to break the JMS specification, always communicate with Messaging Provider through Resource Adapter.
I hope this helps.