Class NotificationListeningMessageProducer
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.jmx.NotificationListeningMessageProducer
- All Implemented Interfaces:
EventListener
,NotificationListener
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,SmartInitializingSingleton
,ApplicationContextAware
,ApplicationListener<ContextRefreshedEvent>
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,MessageProducer
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
public class NotificationListeningMessageProducer
extends MessageProducerSupport
implements NotificationListener, ApplicationListener<ContextRefreshedEvent>
A JMX
NotificationListener
implementation that will send Messages
containing the JMX Notification
instances as their payloads.- Since:
- 2.0
- Author:
- Mark Fisher, Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStart()
Registers the notification listener with the specified ObjectNames.protected void
doStop()
Unregisters the notification listener.Subclasses may implement this method to provide component type information.void
handleNotification
(Notification notification, Object handback) Notification handling method implementation.void
TheNotificationListener
might not be registered onAbstractEndpoint.start()
because theMBeanExporter
might not been started yet.protected Collection<ObjectName>
Return a collection ofObjectName
ofr providedmBeanObjectNames
.void
setFilter
(NotificationFilter filter) Specify aNotificationFilter
to be passed to the server when registering this listener.void
setHandback
(Object handback) Specify a handback object to provide context to the listener upon notification.void
setObjectName
(ObjectName... objectNames) Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.void
setServer
(MBeanServerConnection server) Provide a reference to the MBeanServer where the notification publishing MBeans are registered.Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, isObserved, onInit, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
NotificationListeningMessageProducer
public NotificationListeningMessageProducer()
-
-
Method Details
-
setServer
Provide a reference to the MBeanServer where the notification publishing MBeans are registered.- Parameters:
server
- the MBean server connection.
-
setObjectName
Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.- Parameters:
objectNames
- The object names.
-
setFilter
Specify aNotificationFilter
to be passed to the server when registering this listener. The filter may be null.- Parameters:
filter
- The filter.
-
setHandback
Specify a handback object to provide context to the listener upon notification. This object may be null.- Parameters:
handback
- The object.
-
handleNotification
Notification handling method implementation. Creates a Message with the JMXNotification
as its payload, and if the handback object is not null, it sets that as a Message header value. The Message is then sent to this producer's output channel.- Specified by:
handleNotification
in interfaceNotificationListener
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classIntegrationObjectSupport
-
onApplicationEvent
TheNotificationListener
might not be registered onAbstractEndpoint.start()
because theMBeanExporter
might not been started yet.- Specified by:
onApplicationEvent
in interfaceApplicationListener<ContextRefreshedEvent>
- Parameters:
event
- the ContextRefreshedEvent event
-
doStart
protected void doStart()Registers the notification listener with the specified ObjectNames.- Overrides:
doStart
in classMessageProducerSupport
-
doStop
protected void doStop()Unregisters the notification listener.- Overrides:
doStop
in classMessageProducerSupport
-
retrieveMBeanNames
Return a collection ofObjectName
ofr providedmBeanObjectNames
.- Returns:
- the collection of
ObjectName
ofr providedmBeanObjectNames
.
-