javaspringclassmuleundeploy

How to stop a java class when undeploying a mule application


My Mule application uses a java class which is started as a Spring Bean. This works fine. But I have a problem when I undeploy my application and deploy a newer version.

After I undeploy the application the java process is still active. After deploying the new version of the application, there are two instances of the java class running.

As a solution I have added a shutdown hook to the java class. The hook works, but only when I shutdown Mule itself. Not when I undeploy the app.

To test this I have done the following:

What should I do to stop the java process when I undeploy the application?

Thanks, Jeroen

I am using Mule 3.4.0 and jdk1.7.0_25.


Solution

  • Add a stop method on your class and call it via Spring's destroy-method.