users@glassfish.java.net

Re: Sending messages between two different Glassfish instances

From: Nigel Deakin <Nigel.Deakin_at_Sun.COM>
Date: Fri, 30 Oct 2009 17:22:21 +0000

Nils,

I presume the two Glassfish instances weren't clustered. If they were, the two would exchange messages without the need
for further configuration.

If the instances are not clustered, there are several ways to configure Glassfish to send messages to a different
instance. Here is one simple way:

Sending:

If you want a JMS connection in one instance to send to a MQ broker running in another instance, you need to configure
the addressList property of the connection factory to refer to the other MQ broker.
http://docs.sun.com/app/docs/doc/820-6740/aeoop?a=view

Receiving:

If you want a MDB in one instance to consume messages from a MQ broker running in another instance, you need to
configure the addressList property of its activation spec to refer to the other MQ broker.
http://docs.sun.com/app/docs/doc/820-6740/aeooq?a=view

Format of addressList:

The format of addressList is a URL something like mq://host:port
where "host" is the hostname on which the other instance is running, and "port" is the JMS port it is using. The port is
probably 7676 for a standalone Glassfish instance.

You may see a INFO message when the other instance is started, of the form "JMS Service Connection URL is..." which
should tell you what addressList to use.

Nigel

P.S. I suspect fetching a connection factory from the other instance won't help, since by default a connection factory
will probably refer to localhost.


Nils wrote:
> Dear Glassfish Community
>
> I've realized a simple scenario with two EJB projects: The first
> project sends a JMS message to the second, containing an object the
> second projects receives it (using an MDB and a queue) . It then
> investigates the object and then sends an answer, depending on the
> object back to the first instance.
>
> This works well if I deploy both projects in the same Glassfish
> server, however I didn't get it to work on two different servers. I
> used InitialContext with Properties and set the hostname of the other
> server to create the ConnectionFactory and the Queue. It seems that it
> was able to create the objects using JNDI, but there was no
> communication between the two servers (checked using tcpdump).
>
> I'm not quite sure whether my approach was right, therefore I ask here.
>
> Nils
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>