How to gracefully shut down a Spring JMS MessageListenerAdapter

How to gracefully shut down a Spring JMS MessageListenerAdapter

I have a message handler, which consumes from a JMS queue and that sends results to another JMS queue. The message handler lives in a Spring DefaultMessageListenerContainer. When the container shuts down, I would like for it to finish handling any requests that it already consumed and send out the results. At the same time, it should no longer consume any new messages from the request queue.

Right now, with no special shutdown provisions safe ApplicationContext.registerShutdownHook(), the container waits for any pending listernerMethod invocations to return, but it isn't sending out the results to the response queue.

What would be the appropriate approach for making sure that responses produced by running handlers are sent to the response queue?

How do I set an cache time for objects in OSCache using spring-modules?


Spring: How can you declare name/value pairs outside a Map?
I think the way to go has to lead via DisposableBean interface or @PreDestroy annotation.

Spring MVC isFormSubmission() equivalent for annotations?
The key thing IMHO is not to let Spring shut down the DMLC but rather let this being done by a component that is aware of messages currently "inside the system".

incompatible types found: required: default enums in annotations
This way you stop listening for new messages while waiting for currently proccessed messages to be finished..
application-context.xml problem for Spring ActionScript
Using the depends-on attribute on bean declarations you can also define the order of beans to be shut down.

Disable Outlook Email Forwarding in Java
Red more on this in the Spring reference documentation..
Spring - Ways to include a jar which itself is using Spring in a Spring project

Spring not finding Hibernate mappings file

85 out of 100 based on 65 user ratings 415 reviews