Class MessageCountNotification
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,StateManagedComponent
,WorkflowInterceptor
Notification
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 different
Notification.getMessage()
.
The Notification.setUserData(Object)
part of the notification is a Properties
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 have getMaxNotifications()
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 is
max-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
Modifier and TypeFieldDescriptionstatic final String
TheNotification.getMessage()
when the message count is above the configured threshold.static final String
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the component.void
init()
Initialises the component.void
Set the maximum number of consecutive notifications to emit.void
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 Details
-
NOTIF_MESSAGE_BELOW_THRESHOLD
TheNotification.getMessage()
when the message count is below the configured threshold.- See Also:
-
NOTIF_MESSAGE_ABOVE_THRESHOLD
TheNotification.getMessage()
when the message count is above the configured threshold.- See Also:
-
-
Constructor Details
-
MessageCountNotification
public MessageCountNotification() -
MessageCountNotification
-
MessageCountNotification
-
-
Method Details
-
workflowStart
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
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:
-
init
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
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
-
setMessageCount
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
-
setMaxNotifications
Set the maximum number of consecutive notifications to emit.- Parameters:
i
- the max number of consecutive notifications.
-