This is an alternate version of Distributed Queue that supports assigning IDs to the items added to the queue. Items put into the queue are guaranteed to be ordered (by means of ZK's PERSISTENTSEQUENTIAL node). If a single consumer takes items out of the queue, they will be ordered FIFO. If ordering is important, use a LeaderSelector to nominate a single consumer.
See Distributed Queue for details of using the builder, the only difference is to use the buildIdQueue() method.
The queue must be started via the start() method. Call close() when you are done with the queue.
To add messages to the queue:
To remove messages from the queue:
int numberRemoved = queue.remove(messageId);
Your consumer (QueueConsumer.consumeMessage()) will get called as messages arrive.
The lock safety and error handling are the same as for Distributed Queue.