Feb 14th, 2011, 01:37 PM
Requeue msg with SimpleMessageListenerContainer
I'm working with SimpleMessageListenerContainer (org.springframework.amqp.rabbit.listener) and would like to reorder the messages received by rejecting messages that aren't delivered in order (preferably by throwing an exception) and having them re queued for future handling. Is this possible? How do I define the redelivery policy?
Feb 14th, 2011, 03:44 PM
The redelivery behaviour is basically fixed by the broker (and by the spec): anything that is not delivered is re-inserted at the back of the queue. Hope that works for you.
There are some patterns you could implement to change that behaviour at the application level, e.g. a special queue for redeliveries (we have discussed having this as a framework feature, but it isn't very high on the list for 1.0). The actual order of delivery is always going to be difficult to manage in any great detail since it is the broker that controls the persistence and queue semantics at the protocol level.