Consuming messages from a Hazelcast Queue only once in a distributed environment
posted 3 months ago
I am facing a problem with consuming messages in a distributed environment using hazelcast queue item listeners. The messages are consumed by all nodes/jvms which has subscribed for itemAdded event. I want to receive the itemAdded event only once in one of the nodes, similar to a JMS queue.
When I tried using a queue to publish messages and added an item listener in two different JVMs, I am receiving the messages twice in both of them. I want to receive the message only once in a clustered/distributed environments.
Here's my code snippet:
Publishing of the message:
I have the same listener configured in two different JVMs which goes like this: