Announcement Announcement Module
No announcement yet.
Deploying MDPs in a standalone process Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deploying MDPs in a standalone process

    I was wondering if anyone had any pointers on how to make sure that all the MessageListenerContainers are stopped cleanly when the main method that created the ApplicationContext is stopped.

    During development I have used a very simple main method similar to the one used in this blog entry

    public static void main(String[] args) throws IOException {
    new ClassPathXmlApplicationContext("/blog/mdp/server-context.xml");;
    I am considering using the Java Service Wrapper to start and stop the process, but I need to make sure that the ApplicationContext is stopped correctly so that no components get interrupted in the middle of processing a message.

    Is there a better way to block? Do I need to register any shutdown hooks for closing the AppContext?


  • #2
    You can explore the Spring JMS code and notice that all jms containers extend from AbstractJmsListeningContainer which, in turn, implements org.springframework.context.Lifecycle interface. So, if destroy() method is called, all JMS stuff is stopped. Hence, you only have to be sure that the method is called. For achieving this refer to application context documentation, registerShutdownHook() method in particular.


    • #3
      Thanks, Denis, that was helpful info.