@ManagedResource public class IntegrationMBeanExporter extends MBeanExporter implements BeanPostProcessor, BeanFactoryAware, ApplicationContextAware, BeanClassLoaderAware, SmartLifecycle, Runnable
MBean exporter for Spring Integration components in an existing application. Add an instance of this as a bean definition in the same context as the components you need to monitor and all message channels and message handlers will be exposed.
Channels will report metrics on send and receive (counts, rates, errors) and handlers will report metrics on
execution duration. Channels will be registered under their name (bean id), if explicit, or the last part of their
internal name (e.g. "nullChannel") if registered by the framework. A handler that is attached to an endpoint will be
registered with the endpoint name (bean id) if there is one, otherwise under the name of the input channel. Handler
object names contain a bean
key that reports the source of the name: "endpoint" if the name is the
endpoint id; "anonymous" if it is the input channel; and "handler" as a fallback, where the object name is just the
toString()
of the handler.
This component is itself an MBean, reporting attributes concerning the names and object names of the channels and
handlers. It doesn't register itself to avoid conflicts with the standard <context:mbean-export/>
from Spring (which should therefore be used any time you need to expose those features).
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DOMAIN |
AUTODETECT_ALL, AUTODETECT_ASSEMBLER, AUTODETECT_MBEAN, AUTODETECT_NONE
REGISTRATION_FAIL_ON_EXISTING, REGISTRATION_IGNORE_EXISTING, REGISTRATION_REPLACE_EXISTING, server
Constructor and Description |
---|
IntegrationMBeanExporter() |
adaptMBeanIfPossible, afterPropertiesSet, createAndConfigureMBean, createModelMBean, getObjectName, isBeanDefinitionLazyInit, isMBean, onRegister, onUnregister, registerBeanNameOrInstance, registerManagedResource, registerManagedResource, setAllowEagerInit, setAssembler, setAutodetect, setAutodetectMode, setAutodetectModeName, setBeans, setEnsureUniqueRuntimeObjectNames, setExcludedBeans, setExposeManagedResourceClassLoader, setListeners, setNamingStrategy, setNotificationListenerMappings, setNotificationListeners, unregisterManagedResource
doRegister, doUnregister, getRegisteredObjectNames, getServer, onRegister, setRegistrationBehavior, setRegistrationBehaviorName, setRegistrationPolicy, setServer, unregisterBeans
public static final String DEFAULT_DOMAIN
public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
setBeanClassLoader
in class MBeanExporter
public void setObjectNameStaticProperties(Map<String,String> objectNameStaticProperties)
objectNameStaticProperties
- the objectNameStaticProperties to setpublic void setDefaultDomain(String domain)
spring.application
(which is useful in
SpringSource HQ).domain
- the domain name to setpublic void setComponentNamePatterns(String[] componentNamePatterns)
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
setBeanFactory
in class MBeanExporter
BeansException
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public void setShutdownExecutor(Executor shutdownExecutor)
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
postProcessAfterInitialization
in interface BeanPostProcessor
BeansException
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
postProcessBeforeInitialization
in interface BeanPostProcessor
BeansException
public final boolean isAutoStartup()
isAutoStartup
in interface SmartLifecycle
public final void stop(Runnable callback)
stop
in interface SmartLifecycle
protected void doStop()
protected void doStart()
public void destroy()
destroy
in interface DisposableBean
destroy
in class MBeanExporter
@ManagedOperation public void stopActiveComponents(boolean force, long howLong)
setShutdownExecutor(java.util.concurrent.Executor)
method. When this is provided, the shutdown will be performed on one
of its threads, instead of the calling thread; thus avoiding
the situation where we will wait for the current thread to terminate.
It is not necessary to supply this executor service if the current thread will not, itself, be shutdown as a result of calling this method.
Note: The supplied executor service will not be shut down.
force
- If true, stop the executors with shutdownNow(), canceling
running tasks. Overrides any settings on schedulers/executors. When true
may result in error messages being sent to error channels.howLong
- The time to wait in total for all activities to complete
in milliseconds.public void run()
stopActiveComponents(boolean, long)
.@ManagedOperation public void stopMessageSources()
@ManagedOperation public void stopActiveChannels()
@ManagedOperation public void stopSchedulers()
@ManagedOperation public void stopExecutors()
@ManagedOperation public void stopNonSpringExecutors()
protected final void orderlyShutdownCapableComponentsBefore()
protected final void orderlyShutdownCapableComponentsAfter()
@ManagedMetric(metricType=COUNTER, displayName="MessageChannel Channel Count") public int getChannelCount()
@ManagedMetric(metricType=COUNTER, displayName="MessageHandler Handler Count") public int getHandlerCount()
@ManagedAttribute public String[] getHandlerNames()
@ManagedMetric(metricType=GAUGE, displayName="Active Handler Count") public int getActiveHandlerCount()
@ManagedMetric(metricType=GAUGE, displayName="Queued Message Count") public int getQueuedMessageCount()
@ManagedAttribute public String[] getChannelNames()
public Statistics getHandlerDuration(String name)
public int getSourceMessageCount(String name)
public int getChannelReceiveCount(String name)
@ManagedOperation public Statistics getChannelSendRate(String name)
public Statistics getChannelErrorRate(String name)
protected void registerBeans()
registerBeans
in class MBeanExporter