users@glassfish.java.net

Re: Sending messages between two different Glassfish instances

From: Nigel Deakin <Nigel.Deakin_at_Sun.COM>
Date: Mon, 02 Nov 2009 15:10:27 +0000

Nils,

Nils wrote:
> Hi Nigel
>
> Thanks a lot for your help, without your help, I think I couldn't get
> it to work.
>
> I did a very simple example, which sends a text message to an MDB,
> located on another Glassfish instance. Below a few things I noticed.
>
>> No. The thing to keep in mind is that with two unclustered instances, you have to decide
>> which one is going to handle (and store) the messages, and then configure both sender
>> (connection factory) and consumer (activation spec) to point to the instance you choose.
>
> The MDB must have a queue assigned to it, so this only leaves the
> possibility to have both, the Queue and the ConnectionFactory on the
> host receiving the msg and fetch it from there.

I'm sorry but I don't follow this.

>
> I also didn't had to add the AddressList property to the
> ConnectionFactory, however I added it to the ActivationConfig of the
> MDB.

Let's assume you're sending messages from host A to host B.

On host A you're sending messages, so you need to configure a connection factory. If you omit the addressList from this
connection factory then messages will be sent to the local host (host A).

On host B you're receiving messages using a MDB, so you need to configure an activation spec. You need to configure
addressList on this activation spec to specify that messages will be received from host A. (If you omit this you would
receive messages from host B, which is pointless since host B doesn't have any messages).

>
> One last question: Is it possible to configure Glassfish (or the MDB)
> so, that any host (in a closed network of course) can send messages to
> a queue, which is then processed in an MDB?

Yes

You can configure an application to send messages to a queue located on any Glassfish instance, anywhere on the network.
All you need to do is to set its hostname and JMS port in the addressList property of the connection factory.

You can configure a MDB to consume messages from a queue located on any Glassfish instance, anywhere on the network. All
you need to do is to set its hostname and JMS port in the addressList property of the MDB's activation spec.

Nigel