Class SlowMessageNotification
- java.lang.Object
-
- com.adaptris.core.interceptor.WorkflowInterceptorImpl
-
- com.adaptris.core.interceptor.NotifyingInterceptor
-
- com.adaptris.core.interceptor.SlowMessageNotification
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent,WorkflowInterceptor
@ComponentProfile(summary="Interceptor that issues a JMX notification if a message took too long", tag="interceptor,jmx") public class SlowMessageNotification extends NotifyingInterceptorInterceptor that emits aNotificationif a message has exceeded the specified threshold for processing within a workflow.The
Notification.setUserData(Object)part of the notification is aPropertiesobject containing information about the message that exceeded the interceptors threshold. Note that notifications are emitted whenever a message is deemed to have exceeded the threshold; you might get multiple notifications if a message exceeds the threshold, fails and is automatically retried (which again exceeds the threshold).A cleanup thread is also started as part of this interceptor which purges internal data on a periodic basis; this period is calculated based on the notification threshold (+1 minute) and any messages that are outstanding will have a notification emitted for it, and removed. Because of this, it will be possible to be notified before the message formally exits the workflow, but the notification will still be after the threshold has been exceeded. If this occurs, then the endTime and timeTaken markers are set to
-1- Since:
- 3.0.4
-
-
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.StringKEY_MESSAGE_DURATIONKey within the properties containing the time taken in millisecondsstatic java.lang.StringKEY_MESSAGE_ENDKey within the properties containing the end time in millisecondsstatic java.lang.StringKEY_MESSAGE_IDKey within the properties containing the messageIDstatic java.lang.StringKEY_MESSAGE_STARTKey within the properties containing the start time in millisecondsstatic java.lang.StringKEY_MESSAGE_SUCCESSKey within the properties containing whether the message was successful or not-
Fields inherited from class com.adaptris.core.interceptor.WorkflowInterceptorImpl
log
-
-
Constructor Summary
Constructors Constructor Description SlowMessageNotification()SlowMessageNotification(java.lang.String uid, TimeInterval threshold)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the component.TimeIntervalgetNotifyThreshold()voidinit()Initialises the component.voidsetNotifyThreshold(TimeInterval t)Specify the duration which if exceeded aNotificationwill be sent.voidstart()Starts the component.voidstop()Stop the componentvoidworkflowEnd(AdaptrisMessage inputMsg, AdaptrisMessage outputMsg)Mark the end of a workflow.voidworkflowStart(AdaptrisMessage inputMsg)Mark the start of a workflow.-
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
-
KEY_MESSAGE_ID
public static final java.lang.String KEY_MESSAGE_ID
Key within the properties containing the messageID- See Also:
- Constant Field Values
-
KEY_MESSAGE_START
public static final java.lang.String KEY_MESSAGE_START
Key within the properties containing the start time in milliseconds- See Also:
- Constant Field Values
-
KEY_MESSAGE_END
public static final java.lang.String KEY_MESSAGE_END
Key within the properties containing the end time in milliseconds- See Also:
- Constant Field Values
-
KEY_MESSAGE_DURATION
public static final java.lang.String KEY_MESSAGE_DURATION
Key within the properties containing the time taken in milliseconds- See Also:
- Constant Field Values
-
KEY_MESSAGE_SUCCESS
public static final java.lang.String KEY_MESSAGE_SUCCESS
Key within the properties containing whether the message was successful or not- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SlowMessageNotification
public SlowMessageNotification()
-
SlowMessageNotification
public SlowMessageNotification(java.lang.String uid, TimeInterval threshold)
-
-
Method Detail
-
workflowStart
public void workflowStart(AdaptrisMessage inputMsg)
Description copied from interface:WorkflowInterceptorMark 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:WorkflowInterceptorMark 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 CoreExceptionDescription copied from interface:ComponentLifecycleInitialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException- wrapping any underlyingExceptions
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts 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 underlyingExceptions
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop 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 aRuntimeExceptionmay cause unintended consequences
-
close
public void close()
Description copied from interface:ComponentLifecycleCloses the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeExceptionmay cause unintended consequences
-
getNotifyThreshold
public TimeInterval getNotifyThreshold()
-
setNotifyThreshold
public void setNotifyThreshold(TimeInterval t)
Specify the duration which if exceeded aNotificationwill be sent.- Parameters:
t- the duration, if not specified then 1 minute.
-
-