Class JmxNotificationConsumer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.core.jmx.JmxNotificationConsumer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
,java.util.EventListener
,javax.management.NotificationListener
@ComponentProfile(summary="Listen for notifications against the specified ObjectName", tag="consumer,jmx", metadata="jmxNotificationSource", recommended=JmxConnection.class) public class JmxNotificationConsumer extends AdaptrisMessageConsumerImp implements javax.management.NotificationListener
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
JMX_NOTIF_SOURCE
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description JmxNotificationConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.java.lang.String
consumeLocationKey()
Provides the metadata key '"jmxNotificationSource"' that contains the source of the notifcation.java.lang.Boolean
getFailIfNotFound()
java.lang.String
getObjectName()
The object name which we will register as a listener for.NotificationSerializer
getSerializer()
void
handleNotification(javax.management.Notification notification, java.lang.Object handback)
void
init()
Initialises the component.protected java.lang.String
objectName()
void
prepare()
Prepare for initialisation.void
setFailIfNotFound(java.lang.Boolean b)
Whether or not to fail if the ObjectName is not found.void
setObjectName(java.lang.String objectName)
The object name which we will register as a listener for.void
setSerializer(NotificationSerializer serializer)
void
start()
Starts the component.void
stop()
Stop the component-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Field Detail
-
JMX_NOTIF_SOURCE
public static final java.lang.String JMX_NOTIF_SOURCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
objectName
protected java.lang.String objectName()
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- Specified by:
close
in interfaceComponentLifecycle
-
getSerializer
public NotificationSerializer getSerializer()
- Returns:
- the serializer
-
setSerializer
public void setSerializer(NotificationSerializer serializer)
- Parameters:
serializer
- the serializer to set
-
handleNotification
public void handleNotification(javax.management.Notification notification, java.lang.Object handback)
- Specified by:
handleNotification
in interfacejavax.management.NotificationListener
-
getFailIfNotFound
public java.lang.Boolean getFailIfNotFound()
- Returns:
- the failIfNotFound
-
setFailIfNotFound
public void setFailIfNotFound(java.lang.Boolean b)
Whether or not to fail if the ObjectName is not found.If set to false, and the object is not found, then an attempt will be made periodically to check the MBeanServeConnection for the object instance availability; when it becomes available, the notification listener will be added at that point.
- Parameters:
b
- the failIfNotFound to set, default is true
-
consumeLocationKey
public java.lang.String consumeLocationKey()
Provides the metadata key '"jmxNotificationSource"' that contains the source of the notifcation.- Specified by:
consumeLocationKey
in interfaceAdaptrisMessageConsumer
- Returns:
- the metadata key;
- Since:
- 3.9.0
-
getObjectName
public java.lang.String getObjectName()
The object name which we will register as a listener for.
-
setObjectName
public void setObjectName(java.lang.String objectName)
The object name which we will register as a listener for.
-
-