Class ForEach

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

    @ComponentProfile(summary="Runs the configured service/list for each multi-payload message payload.",
                      tag="for,each,for each,for-each,then,multi-payload",
                      since="3.10.0")
    public class ForEach
    extends ServiceImp
    A for-each implementation that iterates over the payloads in a multi-payload message MultiPayloadAdaptrisMessage. For each payload then execute the given service (list). The default is to use a single thread to iterate over the payloads, but a thread pool can be used to parallelize the loop.
     
     <for-each-payload>
       <unique-id>for-each-id</unique-id>
       <then>
         <service class="shared-service">
           <lookup-name>for-each-service-list-id</lookup-name>
           <unique-id>for-each-service-list-id</unique-id>
         </service>
       </then>
       <thread-count>1</thread-count>
     </for-each-payload>
     
     

    Note: If your service list for each payload contains a StopProcessingService it will not stop the processing of each payload.

    Since:
    3.10
    See Also:
    MultiPayloadAdaptrisMessage

    In the adapter configuration file this class is aliased as for-each-payload which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • ForEach

        public ForEach()
    • Method Detail

      • getThen

        public ThenService getThen()
        Get the for-each-then service.
        Returns:
        The service.
      • setThen

        public void setThen​(ThenService thenService)
        Set the for-each-then service.
        Parameters:
        thenService - The service.
      • getThreadCount

        public java.lang.Integer getThreadCount()
        Get the number of threads to use.
        Returns:
        The number of threads.
      • setThreadCount

        public void setThreadCount​(java.lang.Integer threadCount)
        Set the number of threads to use. If set to 0 then as many threads as there are payloads will be used.
        Parameters:
        threadCount - The number of threads.
      • stop

        public void stop()
        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