Class PooledSplitJoinService

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

    @ComponentProfile(summary="Split a message and then execute the associated services on the split items, aggregating the split messages afterwards",
                      since="3.11.1",
                      tag="service,splitjoin")
    public class PooledSplitJoinService
    extends ServiceImp
    implements EventHandlerAware, ServiceWrapper
    Implementation of the Splitter and Aggregator enterprise integration pattern.

    This has more predictable peformance characteristics in constrained environments where the numbers of messages that are generated and aggregated can be large/unknown.

    This service splits a message according to the configured MessageSplitter implementation, executes the configured Service and subsequently aggregates all the messages back using the configured MessageAggregator implementation

    A pool of Service instances is maintained and re-used for each message; the cost of initialisation for the wrapped service, is incurred during this service's initialisation phase.

    Aggregation may start happening as soon as messages are available to be aggregated (i.e. a split message has been operated on) using the MessageAggregator.aggregate(AdaptrisMessage, Iterable) method. Performance characteristics will largely depend on how the splitter and aggregator implementations iterate over the messages.

    In the adapter configuration file this class is aliased as pooled-split-join-service which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • PooledSplitJoinService

        public PooledSplitJoinService()
    • Method Detail

      • 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

        Specified by:
        stop in interface ComponentLifecycle
        Overrides:
        stop in class ServiceImp
      • doSplitService

        protected java.lang.Iterable<AdaptrisMessage> doSplitService​(java.lang.Iterable<AdaptrisMessage> msgs,
                                                                     com.adaptris.core.services.splitter.PooledSplitJoinService.CountingExceptionHandlerWrapper exceptionHandler)
      • waitQuietly

        protected void waitQuietly​(java.lang.Object monitor,
                                   long timeoutMs)
      • wrappedServices

        public Service[] wrappedServices()
        Description copied from interface: ServiceWrapper
        Return all the services that are wrapped by this service.
        Specified by:
        wrappedServices in interface ServiceWrapper
        Returns:
        an array of wrapped services.
      • getService

        @NonNull
        public @NonNull Service getService()
        The Service to execute over all the split messages.
      • setService

        public void setService​(@NonNull
                               @NonNull Service service)
        The Service to execute over all the split messages.
      • setSplitter

        public void setSplitter​(@NonNull
                                @NonNull MessageSplitter splitter)
        The MessageSplitter implementation to use to split the incoming message.
      • getTimeout

        public TimeInterval getTimeout()
        The max amount of time to wait for all the operations to complete.

        If not explicitly specified then is set to be 10 minutes; in the event that the timeout is exceeded, then an exception will be thrown eventually.

      • setTimeout

        public void setTimeout​(TimeInterval timeout)
        The max amount of time to wait for all the operations to complete.

        If not explicitly specified then is set to be 10 minutes; in the event that the timeout is exceeded, then an exception will be thrown eventually.

      • getSendEvents

        public java.lang.Boolean getSendEvents()
        Whether or not to send events for the split message once service execution has completed.

        Note that even if this is set to true, because each child message has its own unique id, you will have to externally correlate the message lifecycle events together. Child messages will always have the metadata CoreConstants.PARENT_UNIQUE_ID_KEY set with the originating message id.

        If not explicitly specified then is set to false which means no events are sent for 'split' messages.

      • setSendEvents

        public void setSendEvents​(java.lang.Boolean sendEvents)
        Whether or not to send events for the split message once service execution has completed.

        Note that even if this is set to true, because each child message has its own unique id, you will have to externally correlate the message lifecycle events together. Child messages will always have the metadata CoreConstants.PARENT_UNIQUE_ID_KEY set with the originating message id.

        If not explicitly specified then is set to false which means no events are sent for 'split' messages.

      • getPoolsize

        public java.lang.Integer getPoolsize()
        The size of the underlying object/thread pool used to execute services.

        The default value is '10' unless explicitly configured

      • setPoolsize

        public void setPoolsize​(java.lang.Integer poolsize)
        The size of the underlying object/thread pool used to execute services.

        The default value is '10' unless explicitly configured

      • setServiceErrorHandler

        public void setServiceErrorHandler​(ServiceErrorHandler serviceErrorHandler)
        The strategy to use when encountering any errors during execution.

        Defaults to ServiceExceptionHandler if not explicitly specified