SPR-5507 Added support for shutdown order on SmartLifecycle. DefaultLifecycleProcessor now manages the shutdown in phases depending on that order (with a timeout value per group).
This commit is contained in:
@@ -65,6 +65,8 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
|
||||
|
||||
private boolean autoStartup = true;
|
||||
|
||||
private int shutdownOrder = Integer.MAX_VALUE;
|
||||
|
||||
private String beanName;
|
||||
|
||||
private Connection sharedConnection;
|
||||
@@ -116,6 +118,21 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
|
||||
return this.autoStartup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the order in which this container should be stopped.
|
||||
* By default it will be stopped in the last group.
|
||||
*/
|
||||
public void setShutdownOrder(int shutdownOrder) {
|
||||
this.shutdownOrder = shutdownOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the order in which this container will be stopped.
|
||||
*/
|
||||
public int getShutdownOrder() {
|
||||
return this.shutdownOrder;
|
||||
}
|
||||
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -286,6 +303,11 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(Runnable callback) {
|
||||
this.stop();
|
||||
callback.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all invoker tasks and stop the shared Connection, if any.
|
||||
* @throws JMSException if thrown by JMS API methods
|
||||
|
||||
@@ -514,6 +514,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
||||
* @throws JmsException if stopping failed
|
||||
* @see #stop()
|
||||
*/
|
||||
@Override
|
||||
public void stop(Runnable callback) throws JmsException {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
this.stopCallback = callback;
|
||||
|
||||
Reference in New Issue
Block a user