-
1. Re: Storing only most recent message in queue
garytully Jun 18, 2010 7:05 AM (in response to slloyd)Do you really need Queue semantics?
With a topic subscriber in ActiveMQ it is possible to configure a pendingMessageLimit strategy and eviction policy that will ensure that while a batch of messages are being processed, another batch of most recent messages will be stored pending dispatch to that subscriber. Messages that exceed that pending batch limit will be ignored.
With respect to the "Last Value" feature for a queue. This does not exist out of the box but could be easily implemented as a broker interceptor .
For particular queues you could keep track of the last message id with a particular header value (by intercepting Broker.send()) and remove the predecessor before dispatching the most recent. All the apis to do this are easily accessible from an interceptor.
-
2. Re: Storing only most recent message in queue
slloyd Jun 20, 2010 7:44 PM (in response to garytully)Thanks for the pointer to the interceptor documentation - very useful. After a bit of digging around, it appears that I should be able to achieve what I am after by simply intercepting the send() call in the filter and using a JMS selector (using the header value) to remove any matching messages from the Queue. So long as the removeMatchingMessages call is not too slow, this should work nicely (with very little code).
Thanks.