Class CheckUniqueMetadataValueService

  • All Implemented Interfaces:
    AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator, Service, StateManagedComponent

    @ComponentProfile(summary="Perform a branch by checking a metadata key and comparing it against a list of previously received values",
                      tag="service,branching",
                      branchSelector=true)
    public class CheckUniqueMetadataValueService
    extends BranchingServiceImp

    Branching Service implementation which checks the value stored against a configured metadata key against a list of previously received values.

    The service obeys the following rules when checking the metadata key

    • If the looked-up value is null or empty, a ServiceException is thrown.
    • If the value is set and has previously been received, the configured nextServiceIdIfDuplicate is set on the message.
    • If the looked-up value is not contained in the store of previous values nextServiceIdIfUnique is set and the value is added to this store for future checking.
    • The store of previous values has a configurable maximum size. After a new value is added, if the store exceeds the maximum size the oldest value is removed. The store is then persisted to the configured store file.

    In the adapter configuration file this class is aliased as check-unique-metadata-value-service which is the preferred alternative to the fully qualified classname when building your configuration.

    • Field Detail

      • DEFAULT_SERVICE_ID_UNIQUE

        public static final java.lang.String DEFAULT_SERVICE_ID_UNIQUE

        Default next Service ID to set if the message metadata value does not appear in the store of previously received values.

        See Also:
        Constant Field Values
      • DEFAULT_SERVICE_ID_DUPLICATE

        public static final java.lang.String DEFAULT_SERVICE_ID_DUPLICATE

        Default next Service ID to set if the message metadata value does appear in the store of previously received values.

        See Also:
        Constant Field Values
    • Constructor Detail

      • CheckUniqueMetadataValueService

        public CheckUniqueMetadataValueService()

        Creates a new instance. Default history size is 1000.

    • Method Detail

      • getMetadataKeyToCheck

        public java.lang.String getMetadataKeyToCheck()

        Returns the metadata key whose value should be checked.

        Returns:
        metadataKey the metadata key whose value should be checked
      • setMetadataKeyToCheck

        public void setMetadataKeyToCheck​(java.lang.String s)

        Sets the metadata key whose value should be checked. May not be null.

        Parameters:
        s - the metadata key whose value should be checked
      • getNumberOfPreviousValuesToStore

        public int getNumberOfPreviousValuesToStore()

        Returns the number of previous values to keep.

        Returns:
        the number of previous values to keep
      • setNumberOfPreviousValuesToStore

        public void setNumberOfPreviousValuesToStore​(int i)

        Sets the number of previous values to keep. Must be greater than 0.

        Parameters:
        i - the number of previous values to keep
      • getStoreFileUrl

        public java.lang.String getStoreFileUrl()

        Returns the persistent store for previously received values in the form of a file URL. E.g. file:////Users/adaptris/store.dat/.

        Returns:
        the persistent store for previously received values in the form of a file URL
      • setStoreFileUrl

        public void setStoreFileUrl​(java.lang.String s)

        Sets the persistent store for previously received values in the form of a file URL. E.g. file:////Users/adaptris/store.dat. May not be null or empty.

        Parameters:
        s - the persistent store for previously received values in the form of a file URL
      • getNextServiceIdIfDuplicate

        public java.lang.String getNextServiceIdIfDuplicate()

        Returns the ID of the next Service to apply if the metadata exists if the store of previous values.

        Returns:
        the ID of the next Service to apply if the metadata exists if the store of previous values
      • setNextServiceIdIfDuplicate

        public void setNextServiceIdIfDuplicate​(java.lang.String s)

        Sets the ID of the next Service to apply if the metadata exists if the store of previous values. May not be null or empty.

        Parameters:
        s - the ID of the next Service to apply if the metadata exists if the store of previous values
      • getNextServiceIdIfUnique

        public java.lang.String getNextServiceIdIfUnique()

        Returns the ID of the next Service to apply if the metadata does not exist if the store of previous values.

        Returns:
        the ID of the next Service to apply if the metadata does not exist if the store of previous values
      • setNextServiceIdIfUnique

        public void setNextServiceIdIfUnique​(java.lang.String s)

        Sets the ID of the next Service to apply if the metadata does not exist if the store of previous values. May not be null or empty.

        Parameters:
        s - the ID of the next Service to apply if the metadata does not exist if the store of previous values