Class IteratingPipe<I>

All Implemented Interfaces:
HasSender, HasTransactionAttribute, IConfigurable, IConfigurationAware, IForwardTarget, INamedObject, IPipe, IScopeProvider, IWithParameters, EventThrowing, HasStatistics, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
StringIteratorPipe, XmlFileElementIteratorPipe, ZipIteratorPipe

@ElementType(ITERATOR) public abstract class IteratingPipe<I> extends MessageSendingPipe
Abstract base class to send a message to a Sender for each item returned by a configurable iterator.
The output of each of the processing of each of the elements is returned in XML as follows:
  <results count="num_of_elements">
    <result>result of processing of first item</result>
    <result>result of processing of second item</result>
       ...
  </results>
 
For more configuration options, see MessageSendingPipe.
use parameters like:
        <param name="element-name-of-current-item"  xpathExpression="name(/*)" />
        <param name="value-of-current-item"         xpathExpression="/*" />
 
Since:
4.7
Author:
Gerrit van Brakel
  • Field Details

  • Constructor Details

    • IteratingPipe

      public IteratingPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from class: FixedForwardPipe
      checks for correct configuration of forward
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface IPipe
      Overrides:
      configure in class MessageSendingPipe
      Throws:
      ConfigurationException
    • getIterator

      protected IDataIterator<I> getIterator(Message input, PipeLineSession session, Map<String,Object> threadContext) throws SenderException
      Throws:
      SenderException
    • createItemCallBack

      protected IteratingPipe<I>.ItemCallback createItemCallBack(PipeLineSession session, ISender sender, Writer out)
    • itemToMessage

      protected Message itemToMessage(I item) throws SenderException
      Throws:
      SenderException
    • iterateOverInput

      protected IteratingPipe.StopReason iterateOverInput(Message input, PipeLineSession session, Map<String,Object> threadContext, IteratingPipe<I>.ItemCallback callback) throws SenderException, TimeoutException, IOException
      Throws:
      SenderException
      TimeoutException
      IOException
    • sendMessage

      protected PipeRunResult sendMessage(Message input, PipeLineSession session, ISender sender, Map<String,Object> threadContext) throws SenderException, TimeoutException, IOException
      Overrides:
      sendMessage in class MessageSendingPipe
      Throws:
      SenderException
      TimeoutException
      IOException
    • getItem

      protected I getItem(IDataIterator<I> it) throws SenderException
      Throws:
      SenderException
    • getStatisticsKeeper

      @Nonnull protected io.micrometer.core.instrument.DistributionSummary getStatisticsKeeper(String name)
    • setSender

      public void setSender(ISender sender)
      Description copied from class: MessageSendingPipe
      The sender that should send the message
      Overrides:
      setSender in class MessageSendingPipe
    • getStopConditionTp

      protected TransformerPool getStopConditionTp()
    • setStyleSheetName

      public void setStyleSheetName(String styleSheetName)
      Stylesheet to apply to each message, before sending it
    • setXpathExpression

      public void setXpathExpression(String string)
      Alternatively: xpath-expression to create stylesheet from
    • setNamespaceDefs

      public void setNamespaceDefs(String namespaceDefs)
      Namespace defintions for xpathExpression. Must be in the form of a comma or space separated list of prefix=namespaceuri-definitions. For some use other cases (NOT xpathExpression), one entry can be without a prefix, that will define the default namespace.
    • setOutputType

      public void setOutputType(TransformerPool.OutputType outputType)
      Only valid for xpathexpression
      Default value
      text
    • setOmitXmlDeclaration

      public void setOmitXmlDeclaration(boolean b)
      Force the transformer generated from the xpath-expression to omit the xml declaration
      Default value
      true
    • setItemNoSessionKey

      public void setItemNoSessionKey(String string)
      Key of session variable to store number of items processed, i.e. the position or index in the set of items to be processed. When handling the first item, the value will be 1.
    • setMaxItems

      public void setMaxItems(int maxItems)
      The maximum number of items returned. The (default) value of 0 means unlimited, all available items will be returned. Special forward "maxItemsReached" can be configured to follow
      Default value
      0
    • setStopConditionXPathExpression

      public void setStopConditionXPathExpression(String string)
      Expression evaluated on each result and forwards to ["stopConditionMet"] forward if configured. Iteration stops if condition returns anything other than an empty result. To test for the root element to have an attribute 'finished' with the value 'yes', the expression *[@finished='yes'] can be used. This can be used if the condition to stop can be derived from the item result. To stop after a maximum number of items has been processed, use maxItems. Previous versions documented that position()=2 could be used. This is not working as expected; Use maxItems instead
    • setIgnoreExceptions

      public void setIgnoreExceptions(boolean b)
      When true ignore any exception thrown by executing sender
      Default value
      false
    • setCollectResults

      public void setCollectResults(boolean b)
      Controls whether all the results of each iteration will be collected in one result message. If set false, only a small summary is returned. Setting this attributes to false is often required to enable processing of very large files. N.B. Remember in such a case that setting transactionAttribute to NotSupported might be necessary too
      Default value
      true
    • setRemoveXmlDeclarationInResults

      public void setRemoveXmlDeclarationInResults(boolean b)
      Postprocess each partial result, to remove the xml-declaration, as this is not allowed inside an xml-document
      Default value
      false
    • setAddInputToResult

      public void setAddInputToResult(boolean b)
      When true the input is added to the result in an input element
      Default value
      false
    • setRemoveDuplicates

      public void setRemoveDuplicates(boolean b)
      When true duplicate input elements are removed, i.e. they are handled only once
      Default value
      false
    • setCloseIteratorOnExit

      protected void setCloseIteratorOnExit(boolean b)
    • setParallel

      public void setParallel(boolean parallel)
      When set true, the calls for all items are done in parallel (a new thread is started for each call). when collectresults set true, this pipe will wait for all calls to finish before results are collected and pipe result is returned
      Default value
      false
    • setMaxChildThreads

      public void setMaxChildThreads(int maxChildThreads)
      Maximum number of child threads that may run in parallel simultaneously (combined total of all threads calling this pipe). Use 0 for unlimited threads
      Default value
      0
    • setBlockSize

      public void setBlockSize(int i)
      Controls multiline behaviour. When set to a value greater than 0, it specifies the number of rows send, in a one block, to the sender.
      Default value
      0
    • getStyleSheetName

      public String getStyleSheetName()
    • getXpathExpression

      public String getXpathExpression()
    • getNamespaceDefs

      public String getNamespaceDefs()
    • getOutputType

      public TransformerPool.OutputType getOutputType()
    • isOmitXmlDeclaration

      public boolean isOmitXmlDeclaration()
    • getItemNoSessionKey

      public String getItemNoSessionKey()
    • getStopConditionXPathExpression

      public String getStopConditionXPathExpression()
    • getMaxItems

      public int getMaxItems()
    • isIgnoreExceptions

      public boolean isIgnoreExceptions()
    • isCollectResults

      public boolean isCollectResults()
    • isRemoveXmlDeclarationInResults

      public boolean isRemoveXmlDeclarationInResults()
    • isAddInputToResult

      public boolean isAddInputToResult()
    • isRemoveDuplicates

      public boolean isRemoveDuplicates()
    • isCloseIteratorOnExit

      public boolean isCloseIteratorOnExit()
    • isParallel

      public boolean isParallel()
    • getMaxChildThreads

      public int getMaxChildThreads()
    • getBlockSize

      public int getBlockSize()
    • getTaskExecutor

      public org.springframework.core.task.TaskExecutor getTaskExecutor()
    • setTaskExecutor

      public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)