users@glassfish.java.net

Re: Using JMS for duplex communication

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Tue, 18 Jan 2011 16:19:04 +0000

Peter,

On 18/01/2011 15:22, Major Péter wrote:
> Hi,
>
> I'm trying to set up a JMS proof-of-concept, but I'm lost now. The goal is, that an enterprise project will produce
> messages in a topic, and other enterprise projects will consume from that topic. But, it is also required, that these
> small client applications has their own Queues, and the 'master' application will consume from those queues too. The
> 'master' app and the client apps they're all on different machines.
>
> So what I did for now, is I wrote an application, which creates a Topic and produces new messages, this is inside a
> session bean, and opening a servlet triggers this producing. On the other side there is a messagedriven bean, which is
> only configured by annotations. In the client apps container the topicconnectionfactory has the following property for
> now: "AddressList=mq://localhost:7676/jms"
>
> Now if I start up these two projects messages are not received at the client apps, BUT if I change the client apps
> server from EMBEDDED mode to REMOTE mode, and set the JMS service to use the 'master's JMS service, then after a restart
> messages are received, and it looks like everything works.
>
> But if the client apps JMS service is on the remote host, how could I create my queue on the client machine?? Is it
> possible to access with EMBEDDED JMS service a remote Topic? If yes, how?

By default, applications will connect to the JMS broker defined in the JMS service configuration (in your examples,
either the embedded broker or the remote broker). You can also override this on a per-connection basis by configuring
the connection factory explicitly. So it sounds as if you've basically got it right.

> What did I do wrong?

Are you asking why setting "AddressList=mq://localhost:7676/jms" in the topic connection factory on your "client app"
didn't cause it to receive messages from the "master app" running on a different machine?

First thing, you need to replace "localhost" with the hostname on which your "master app" was running.

Was this for a MDB? In this case you need to set addressList on the MDB something like this:

@MessageDriven(name="foo", mappedName = "bar", activationConfig = {
     @ActivationConfigProperty(propertyName = "AddressList", propertyValue = "mq://somehost:7676")
})

Nigel

>
> //I'm using GlassFish v2.1.1
>
> Thanks,
> Peter