6
votes

I am currently writing a distributed system using hazelcast. I have a few questions regarding Queues implemented using hazelcast.

  1. What is the best way to process data from the Queue? I currently have threads on each "node" reading off the blocking queue processing the data. Is this correct or is there some class I am not aware of that takes care of this like JMS or messageListener?
  2. I see there is a time-to-live-seconds setting which will remove the entry from the Queue once expired. My question is... is there any way to detect the removal of an expired item from the Queue? I know there are Listeners but this does not help as this is fired on all the "nodes" and not just one. I am looking for a way of executing code for each expired message (similar to a dead letter queue).

Any input or advice on this matter would be greatly appreciated.

Thanks

1

1 Answers

9
votes
  1. There is no other way at the moment. So you will have your threads on each node calling queue.take(). Hazelcast team is planning to add IQueue.addQueueConsumer(QueueConsumer) that will behave similar to JMS MessageListener

  2. You are right. Adding listeners is not good way of doing it as it is very expensive operation. You might want to create an issue for this at http://code.google.com/p/hazelcast/issues. It is surely nice to have feature.

-talip @ hazelcast