As described in "MBean Exporter", the MBean exporter provides a JMX operation called
stopActiveComponents, which is used to stop the application in an orderly manner.
The operation has a single
The parameter indicates how long (in milliseconds) the operation waits to allow in-flight messages to complete.
The operation works as follows:
beforeShutdown()on all beans that implement
Doing so lets such components prepare for shutdown. Examples of components that implement this interface and what they do with this call include JMS and AMQP message-driven adapters that stop their listener containers, TCP server connection factories that stop accepting new connections (while keeping existing connections open), TCP inbound endpoints that drop (log) any new messages received, and HTTP inbound endpoints that return
503 - Service Unavailablefor any new requests.
Stop any active channels, such as JMS- or AMQP-backed channels.
Stop all inbound
MessageProducers (that are not
Wait for any remaining time left, as defined by the value of the
Longparameter passed in to the operation.
Doing so lets any in-flight messages complete their journeys. It is therefore important to select an appropriate timeout when invoking this operation.
Doing so lets such components perform final shutdown tasks (closing all open sockets, for example).
As discussed in Orderly Shutdown Managed Operation, this operation can be invoked by using JMX.
If you wish to programmatically invoke the method, you need to inject or otherwise get a reference to the
id attribute is provided on the
<int-jmx:mbean-export/> definition, the bean has a generated name.
This name contains a random component to avoid
ObjectName collisions if multiple Spring Integration contexts exist in the same JVM (
For this reason, if you wish to invoke the method programmatically, we recommend that you provide the exporter with an
id attribute so that you can easily access it in the application context.
Finally, the operation can be invoked by using the
See the monitoring Spring Integration sample application for details.
The algorithm described earlier was improved in version 4.1.
Previously, all task executors and schedulers were stopped.
This could cause mid-flow messages in