0

I'm working on a distributed system, written in Java, which is using a Hazelcast IQueue (non Javadoc documentation). I am using Hazelcast 3.12, and for business reasons, do not have the ability to change this version.

One one node, I have a thread calling poll. In another thread on that same node, I am calling drainTo, a method in the BlockingQueue interface that IQueue implements.

The behavior I expect to see is that any thread calling poll (on the same node, or on a different node in the distributed system) does not see the same queue elements that I get in the drainTo call. What I instead see is that sometimes, the thread that's running poll sees an element that's also in the drainTo call.

I don't see this behavior if I swap out the Hazelcast IQueue with an undistributed LinkedBlockingQueue. This makes sense given the answers on this question.

My questions are:

  • Am I wrong in expecting that the contract of BlockingQueue includes this "exclusivity" in the elements seen when calling poll and drainTo in different threads?
  • Is there a way to get all the elements of the queue at once such that I never see any duplicate elements in this "multiple consumers" scenario?
kashev
  • 382
  • 2
  • 15
  • Maybe something else is going on but what you described is not expected. If you have a reproducer better to create an issue here: https://github.com/hazelcast/hazelcast/issues/new/choose – mrck Jun 16 '23 at 07:23
  • Definitely, it should work similar to LinkedBlockingQueue. A reproducer would help to understand. – ihsan demir Jun 16 '23 at 14:06

0 Answers0