Package org.frankframework.pipes
Class IteratingPipe<I>
java.lang.Object
org.frankframework.core.TransactionAttributes
org.frankframework.pipes.AbstractPipe
org.frankframework.pipes.FixedForwardPipe
org.frankframework.pipes.MessageSendingPipe
org.frankframework.pipes.IteratingPipe<I>
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasSender,HasTransactionAttribute,IConfigurable,IForwardTarget,IPipe,IScopeProvider,IWithParameters,NameAware,EventThrowing,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle
- Direct Known Subclasses:
ForEachAttachmentPipe,StringIteratorPipe,ZipIteratorPipe
@Forward(name="maxItemsReached",description="the iteration stopped when the configured maximum number of items was processed") @Forward(name="stopConditionMet",description="the iteration stopped when the configured condition expression became true")
@EnterpriseIntegrationPattern(ITERATOR)
public abstract class IteratingPipe<I>
extends MessageSendingPipe
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:
use parameters like:
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected static enumNested classes/interfaces inherited from class org.frankframework.pipes.MessageSendingPipe
MessageSendingPipe.LinkMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected TransformerPoolprotected static final StringFields inherited from class org.frankframework.pipes.MessageSendingPipe
configurationMetrics, INPUT_VALIDATOR_NAME_PREFIX, INPUT_VALIDATOR_NAME_SUFFIX, INPUT_WRAPPER_NAME_PREFIX, INPUT_WRAPPER_NAME_SUFFIX, MAX_RETRY_INTERVAL, MESSAGE_LOG_NAME_PREFIX, MESSAGE_LOG_NAME_SUFFIX, MIN_RETRY_INTERVAL, msgLog, OUTPUT_VALIDATOR_NAME_PREFIX, OUTPUT_VALIDATOR_NAME_SUFFIX, OUTPUT_WRAPPER_NAME_PREFIX, OUTPUT_WRAPPER_NAME_SUFFIX, PIPE_CLEAR_TIMEOUT_MONITOR_EVENT, PIPE_EXCEPTION_MONITOR_EVENT, PIPE_TIMEOUT_MONITOR_EVENTFields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUniqueFields inherited from class org.frankframework.core.TransactionAttributes
logFields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks for correct configuration of forward.protected IteratingPipe<I>.ItemCallbackcreateItemCallBack(PipeLineSession session, ISender sender, Writer out) protected IgetItem(IDataIterator<I> it) protected IDataIterator<I> getIterator(Message input, PipeLineSession session, Map<String, Object> threadContext) protected io.micrometer.core.instrument.DistributionSummarygetStatisticsKeeper(String name) protected TransformerPoolprotected MessageitemToMessage(I item) protected IteratingPipe.StopReasoniterateOverInput(Message input, PipeLineSession session, Map<String, Object> threadContext, IteratingPipe<I>.ItemCallback callback) protected PipeRunResultsendMessage(Message input, PipeLineSession session, ISender sender, Map<String, Object> threadContext) voidsetAddInputToResult(boolean b) Whentruethe input is added to the result in an input elementvoidsetBlockSize(int i) Controls multiline behaviour.protected voidsetCloseIteratorOnExit(boolean b) voidsetCollectResults(boolean b) Controls whether all the results of each iteration will be collected in one result message.voidsetIgnoreExceptions(boolean b) Whentrueignore any exception thrown by executing sendervoidsetItemNoSessionKey(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.voidsetMaxChildThreads(int maxChildThreads) Maximum number of child threads that may run in parallel simultaneously (combined total of all threads calling this pipe).voidsetMaxItems(int maxItems) The maximum number of items returned.voidsetNamespaceDefs(String namespaceDefs) Namespace defintions for xpathExpression.voidsetOmitXmlDeclaration(boolean b) Force the transformer generated from the xpath-expression to omit the xml declarationvoidsetOutputType(TransformerPool.OutputType outputType) Only valid for xpathexpressionvoidsetParallel(boolean parallel) When settrue, the calls for all items are done in parallel (a new thread is started for each call). when collectresults settrue, this pipe will wait for all calls to finish before results are collected and pipe result is returnedvoidsetRemoveDuplicates(boolean b) Whentrueduplicate input elements are removed, i.e. they are handled only oncevoidsetRemoveXmlDeclarationInResults(boolean b) Postprocess each partial result, to remove the xml-declaration, as this is not allowed inside an xml-documentvoidThe sender that should send the messagevoidExpression evaluated on each result and forwards to ["stopConditionMet"<I>] forward if configured.voidsetStyleSheetName(String styleSheetName) Stylesheet to apply to each message, before sending itvoidsetXpathExpression(String string) Alternatively: xpath-expression to create stylesheet fromMethods inherited from class org.frankframework.pipes.MessageSendingPipe
consumesSessionVariable, doLogToMessageLog, doPipe, increaseRetryIntervalAndWait, postSendAction, propagateName, sendMessageWithRetries, setCheckRootTag, setCheckXmlWellFormed, setExceptionOnResult, setHideMethod, setHideRegex, setInputValidator, setInputWrapper, setLinkMethod, setMaxRetries, setMessageLog, setName, setOutputValidator, setOutputWrapper, setPresumedTimeOutInterval, setResultOnTimeOut, setRetryMaxInterval, setRetryMinInterval, setRetryNamespaceDefs, setRetryXPath, setStubFilename, setTimeoutOnResult, setTimeOutOnResult, sizeStatisticsEnabled, start, stop, storeMessageMethods inherited from class org.frankframework.pipes.FixedForwardPipe
getParameterValue, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipeMethods inherited from class org.frankframework.pipes.AbstractPipe
addForward, addParameter, createBean, findForward, getAdapter, getEventSourceName, getForwards, getParameterList, hasRegisteredForward, isRunning, registerEvent, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setGetInputFromFixedValue, setGetInputFromSessionKey, setLocker, setLogIntermediaryResults, setMaxThreads, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, throwEventMethods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, isTransacted, isTransacted, setTransacted, setTransactionTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.HasTransactionAttribute
getTransactionAttribute, getTransactionTimeout, getTxDef, setTransactionAttributeMethods inherited from interface org.frankframework.core.IForwardTarget
getNameMethods inherited from interface org.frankframework.core.IPipe
getChompCharSize, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getSecLogSessionKeys, getStoreResultInSessionKey, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, setPipeLine, throwEvent
-
Field Details
-
MAX_ITEMS_REACHED_FORWARD
- See Also:
-
STOP_CONDITION_MET_FORWARD
- See Also:
-
msgTransformerPool
-
-
Constructor Details
-
IteratingPipe
public IteratingPipe()
-
-
Method Details
-
configure
Description copied from class:FixedForwardPipeChecks for correct configuration of forward.- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classMessageSendingPipe- Throws:
ConfigurationException- in case it was not able to configure the component.
-
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
- Throws:
SenderException
-
iterateOverInput
protected IteratingPipe.StopReason iterateOverInput(Message input, PipeLineSession session, Map<String, Object> threadContext, IteratingPipe<I>.ItemCallback callback) throws SenderException, TimeoutException, IOException -
sendMessage
protected PipeRunResult sendMessage(Message input, PipeLineSession session, ISender sender, Map<String, Object> threadContext) throws SenderException, TimeoutException, IOException- Overrides:
sendMessagein classMessageSendingPipe- Throws:
SenderExceptionTimeoutExceptionIOException
-
getItem
- Throws:
SenderException
-
getStatisticsKeeper
@Nonnull protected io.micrometer.core.instrument.DistributionSummary getStatisticsKeeper(String name) -
setSender
Description copied from class:MessageSendingPipeThe sender that should send the message- Overrides:
setSenderin classMessageSendingPipe
-
getStopConditionTp
-
setStyleSheetName
Stylesheet to apply to each message, before sending it -
setXpathExpression
Alternatively: xpath-expression to create stylesheet from -
setNamespaceDefs
Namespace defintions for xpathExpression. Must be in the form of a comma or space separated list ofprefix=namespaceuri-definitions. For some use other cases (NOT xpathExpression), one entry can be without a prefix, that will define the default namespace. -
setOutputType
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
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"<I> can be configured to follow- Default value
- 0
-
setStopConditionXPathExpression
Expression evaluated on each result and forwards to ["stopConditionMet"<I>] 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, usemaxItems. Previous versions documented thatposition()=2could be used. This is not working as expected; Use maxItems instead -
setIgnoreExceptions
public void setIgnoreExceptions(boolean b) Whentrueignore 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. Iffalse, only a small summary is returned. Setting this attributes tofalseis 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) Whentruethe input is added to the result in an input element- Default value
- false
-
setRemoveDuplicates
public void setRemoveDuplicates(boolean b) Whentrueduplicate 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 settrue, the calls for all items are done in parallel (a new thread is started for each call). when collectresults settrue, 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). Use0for 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
-