Hazelcast Queue ItemListener for Pending Item (Producer-Consumer Concept)

910 views Asked by At

I have 2 nodes that use Hazelcast.

Node A is a Producer, it puts items into a Queue

Node B is a Consumer, it consume or pool items from the Queue. I add ItemListener into Node B so when an item added to the queue, the consumer will notice and start to consume.

There's nothing wrong if everything work fine, but.. Sometimes the consumer is shutdown, and the producer still working and put item to the queue. When I start the consumer again, it just consume when the producer add an item. So.. how about the pending item.

I'm using Hazelcast 3.3.

Is there any solution for this problem..?

Thanks.

1

There are 1 answers

0
Manuel Garcia de Vinuesa On

It not a bug, the ItemListener is a listener so it is fired when add/remove items so you have to add a new functionality when your consumer starts to check if there are any pending element in the queue.

In my case I just create a heartbeat to ask the queue if there are any element, in that case the consumer method is executed.