Class 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 a 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.

    • Field Detail

      • NOTIF_MESSAGE_BELOW_THRESHOLD

        public static final java.lang.String NOTIF_MESSAGE_BELOW_THRESHOLD
        The Notification.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
        The Notification.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 inputMsg
        outputMsg - 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 underlying Exceptions
      • 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 underlying Exceptions
      • stop

        public void stop()
        Description copied from interface: ComponentLifecycle
        Stop the component

        A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer, calling stop will pause message delivery. Throwing a RuntimeException 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.