Class MetadataTotalsInterceptor

  • All Implemented Interfaces:
    AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, StateManagedComponent, WorkflowInterceptor

    @ComponentProfile(summary="Interceptor that adds the metadata value to an existing counter",
                      tag="interceptor")
    public class MetadataTotalsInterceptor
    extends MetadataMetricsInterceptorImpl
    WorkflowInterceptor implementation that exposes metrics about integer metadata values via JMX.

    Each message that passes through the interceptor will be queried in turn for each configured key (getMetadataKeys()). The integer value associated with that key will be added to the existing total for that key within the given time period.

    The general use-case is when you capture a count of some description (e.g. number of lines), store it against metadata, and to keep a running total of that number for a given time interval. The counts are exposed via MetadataStatisticsMBean for capture and display. Note that if the metadata keys contain non-numeric values, then results are undefined (at the very least you will get NumberFormatException being thrown).

    In the adapter configuration file this class is aliased as metadata-totals-interceptor which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • MetadataTotalsInterceptor

        public MetadataTotalsInterceptor()
      • MetadataTotalsInterceptor

        public MetadataTotalsInterceptor​(java.util.List<java.lang.String> keys)
    • 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
      • getMetadataKeys

        public java.util.List<java.lang.String> getMetadataKeys()
      • setMetadataKeys

        public void setMetadataKeys​(java.util.List<java.lang.String> l)
        Set the list of metadata keys to track.
        Parameters:
        l - the metadata keys.