users@glassfish.java.net

Publishing to JMS Clients on Multiple Machines

From: <glassfish_at_javadesktop.org>
Date: Mon, 17 Sep 2007 15:32:53 PDT

How can I publish a JMS Message to a topic on one host running GlassFish and have multiple clients on multiple GlassFish instances (each hosted on a different machine) receive the original message on each server's topic? In other words, I want to have the Producer on be on Instance A and have several Consumers (say Instance B, Instance C, and Instance D) be able to subscribe to a topic that Instance A publishes to and have all three client instances receive the message when it is published.

I have tried to use the AddressList property with a ConnectionFactory, but this seems to allow multiple hosts to be specified but with only one of the hosts (depending on AddressListBehavior's setting it is either the first or random) actually receiving the published message. Note that I needed to change my JMS Service type from EMBEDDED to LOCAL as described at http://forums.java.net/jive/thread.jspa?messageID=235289 to make even this work correctly for me.

My current thinking is that I cannot do this with GlassFish with a single ConnectionFactory. I believe I could create a ConnectionFactory for each of the three Consumer instances, but that would involve hard-coding the number of Connection Factories in my code. If I had a fourth JMS instance with a client that needed to subscribe, I'd need to add a fourth connection factory. I'd rather continue using dependency injection to inject one Connection Factory that has the capability of allowing multiple JMS brokers on multiple machines receive the same message published to a topic they all have clients subscribing to. Currently, it seems like I can express multiple hosts with AddressList, but only one of them will receive and process the message.

Thanks in advance for any assistance you can provide.
[Message sent by forum member 'ddmarx' (ddmarx)]

http://forums.java.net/jive/thread.jspa?messageID=235717