Class MessageCountNotification
- java.lang.Object
-
- com.adaptris.core.interceptor.WorkflowInterceptorImpl
-
- com.adaptris.core.interceptor.NotifyingInterceptor
-
- com.adaptris.core.interceptor.NotifyingInterceptorByCount
-
- com.adaptris.core.interceptor.MessageCountNotification
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,StateManagedComponent
,WorkflowInterceptor
@ComponentProfile(summary="Interceptor that issues a JMX notification based on a message count boundary", tag="interceptor,jmx") public class MessageCountNotification extends NotifyingInterceptorByCount
Interceptor that emits aNotification
under based on message count being higher or lower than the given message count.A Notification will be emitted when the message count threshold is first exceeded in the last complete timeslice. Notifications will continue being emitted for as long as the message count is greater than the threshold and
getMaxNotifications()
has not been exceeded. When the message count dips below the threshold a notification is emitted with a differentNotification.getMessage()
.The
Notification.setUserData(Object)
part of the notification is aProperties
object containing information about the slice which was the source of the notification. Notifications are only generated based on the last complete timeslice that was recorded when a message enters the workflow. Note that a workflow which does not process any messages within a given timeslice will never rollover the current timeslice so this means that notifications are not generated until the current timeslice rolls over or a message is next processed by the workflow. Any delay in notifications will be based on the spikiness of the traffic and the granularity of your timeslice.Additionally, this interceptor will notify a consecutive maximum of
getMaxNotifications()
(if not specified, then notifications continue forever) whenever a boundary is breached. For instance, if you havegetMaxNotifications()
set to 5, then a maximum of 5 notifications will be emitted for an upper boundary breach provided no lower boundary breaches happen in-between. If the configuration ismax-notifications=3, message-count=10
then our notifications happen like this:|--Timeslice--|--MsgCount--|--Upper Boundary Notification--|--Lower Boundary Notification--| | 01 | 11 | No (no previous timeslice) | No | | 02 | 12 | Yes (count = 11) | No | | 03 | 13 | Yes (count = 12) | No | | 04 | 00 | No | No | | 05 | 11 | Yes, (13) timeslice changed | No | | 06 | 01 | No | No | | 07 | 11 | No | Yes (count=1) | | 08 | 12 | Yes (count = 11) | No | | 09 | 13 | Yes (count = 12) | No | | 10 | 14 | Yes (count = 13) | No | | 11 | 01 | No, as max exceeded | No |
- Since:
- 3.0.4
In the adapter configuration file this class is aliased as message-count-notification which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.interceptor.WorkflowInterceptorImpl
WorkflowInterceptorImpl.WorkflowInterceptorException
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NOTIF_MESSAGE_ABOVE_THRESHOLD
TheNotification.getMessage()
when the message count is above the configured threshold.static java.lang.String
NOTIF_MESSAGE_BELOW_THRESHOLD
TheNotification.getMessage()
when the message count is below the configured threshold.-
Fields inherited from class com.adaptris.core.interceptor.NotifyingInterceptorByCount
KEY_MESSAGE_COUNT, KEY_MESSAGE_ERROR, KEY_MESSAGE_SIZE, KEY_TIMESLICE_END, KEY_TIMESLICE_START
-
Fields inherited from class com.adaptris.core.interceptor.WorkflowInterceptorImpl
log
-
-
Constructor Summary
Constructors Constructor Description MessageCountNotification()
MessageCountNotification(java.lang.String uid)
MessageCountNotification(java.lang.String uid, TimeInterval duration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.java.lang.Integer
getMaxNotifications()
java.lang.Integer
getMessageCount()
void
init()
Initialises the component.void
setMaxNotifications(java.lang.Integer i)
Set the maximum number of consecutive notifications to emit.void
setMessageCount(java.lang.Integer l)
Set the upper boundary over which notifications will be emitted.void
start()
Starts the component.void
stop()
Stop the componentvoid
workflowEnd(AdaptrisMessage inputMsg, AdaptrisMessage outputMsg)
Mark the end of a workflow.void
workflowStart(AdaptrisMessage inputMsg)
Mark the start of a workflow.-
Methods inherited from class com.adaptris.core.interceptor.NotifyingInterceptorByCount
asProperties, getAndIncrementStatistic, getCurrentTimeSlice, getTimesliceDuration, setTimesliceDuration
-
Methods inherited from class com.adaptris.core.interceptor.WorkflowInterceptorImpl
changeState, getUniqueId, parentChannel, parentWorkflow, prepare, registerParentChannel, registerParentWorkflow, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setUniqueId, wasSuccessful
-
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.WorkflowInterceptor
processingStart
-
-
-
-
Field Detail
-
NOTIF_MESSAGE_BELOW_THRESHOLD
public static final java.lang.String NOTIF_MESSAGE_BELOW_THRESHOLD
TheNotification.getMessage()
when the message count is below the configured threshold.- See Also:
- Constant Field Values
-
NOTIF_MESSAGE_ABOVE_THRESHOLD
public static final java.lang.String NOTIF_MESSAGE_ABOVE_THRESHOLD
TheNotification.getMessage()
when the message count is above the configured threshold.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MessageCountNotification
public MessageCountNotification()
-
MessageCountNotification
public MessageCountNotification(java.lang.String uid)
-
MessageCountNotification
public MessageCountNotification(java.lang.String uid, TimeInterval duration)
-
-
Method Detail
-
workflowStart
public void workflowStart(AdaptrisMessage inputMsg)
Description copied from interface:WorkflowInterceptor
Mark the start of a workflow. This doesn't mean the message has started processing but only that the message will - at some point - be processed by the workflow.- Parameters:
inputMsg
- the message that will be processed by this workflow.
-
workflowEnd
public void workflowEnd(AdaptrisMessage inputMsg, AdaptrisMessage outputMsg)
Description copied from interface:WorkflowInterceptor
Mark the end of a workflow.- Parameters:
inputMsg
- the original message that was originally submitted to the workflow; in the event of an exception during processing, the exception will be stored in object metadata in the inputMsgoutputMsg
- the message contaning any changes that may have been applied by the services within the workflow.- See Also:
CoreConstants.OBJ_METADATA_EXCEPTION
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- 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.- 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
-
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
-
getMessageCount
public java.lang.Integer getMessageCount()
-
setMessageCount
public void setMessageCount(java.lang.Integer l)
Set the upper boundary over which notifications will be emitted.- Parameters:
l
- the threshold, defaults to null which means no notification on this boundary
-
getMaxNotifications
public java.lang.Integer getMaxNotifications()
-
setMaxNotifications
public void setMaxNotifications(java.lang.Integer i)
Set the maximum number of consecutive notifications to emit.- Parameters:
i
- the max number of consecutive notifications.
-
-