Back Forum Reply New

How to configure multiples consumers on a single destination

Hi,

Our program uses the SimpleMessageListenerContainer class to listen on a physical queue and processes the incoming messages (code put in the onMethod method).

We would like for performance and availibility reasons to start several consumers on the same queue.
I started 2 instances but i noticed that each one consumes all the messages and therefore the messages are processed in double.
How can we achieve our goal ? Is it possible to synchronize on the queue or to lock the message to avoid duplicate message processing.

If we defined a cluster of queues how will it work ?

Thanks a lot.

Hello.
I use such configuration for multiple consumers on clustered queue:

HTML Code: lt;si:gateway id=quot;gatewayquot; service-interface=quot;com.my.example.Gatewayquot;/gt;
lt;jee:jndi-lookup id=quot;queuequot; jndi-name=quot;queue/Queuequot;/gt;  
lt;si:channel id=quot;inputChannelquot;gt;    lt;si:queue/gt;lt;/si:channelgt;
lt;si:channel id=quot;outpuChannelquot;gt;    lt;si:queue/gt;lt;/si:channelgt;
lt;jmsutbound-channel-adapter channel=quot;inputChannelquot; destination=quot;queuequot;/gt;
lt;jms:message-driven-channel-adapter destination=quot;queuequot; channel=quot;outpuChannelquot;/gt;
lt;siutbound-channel-adapter channel=quot;outpuChannelquot; ref=quot;servicequot; method=quot;methodquot;/gt;
Where:

Code:
public interface Gateway {   @Gateway(requestChannel = quot;inputChannelquot;)   void invoke(Object object);
}
And the queue/Queue is configured in AS-container as clustered.

So, only one consumer eats a message from queue.

Good luck,
Artem Bilan

Hi,

But how to avoid duplicate processing of messages with SimpleMessageListener if 2 instances of the Java process are launched ?

Thanks a lot.

May be your destination isn't Point-to-Point channel. May be it is a Publish-Subsribe channel. In JMS it is a Topic
¥
Back Forum Reply New