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:
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
@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")
@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:
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
Modifier and TypeClassDescriptionprotected class
protected static enum
Nested classes/interfaces inherited from class org.frankframework.pipes.MessageSendingPipe
MessageSendingPipe.LinkMethod
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected TransformerPool
protected static final String
Fields 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_EVENT
Fields inherited from class org.frankframework.pipes.AbstractPipe
parameterNamesMustBeUnique
Fields inherited from class org.frankframework.core.TransactionAttributes
log
Fields inherited from interface org.frankframework.core.IPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checks for correct configuration of forwardprotected IteratingPipe<I>.ItemCallback
createItemCallBack
(PipeLineSession session, ISender sender, Writer out) int
protected I
getItem
(IDataIterator<I> it) protected IDataIterator<I>
getIterator
(Message input, PipeLineSession session, Map<String, Object> threadContext) int
int
protected io.micrometer.core.instrument.DistributionSummary
getStatisticsKeeper
(String name) protected TransformerPool
org.springframework.core.task.TaskExecutor
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
protected Message
itemToMessage
(I item) protected IteratingPipe.StopReason
iterateOverInput
(Message input, PipeLineSession session, Map<String, Object> threadContext, IteratingPipe<I>.ItemCallback callback) protected PipeRunResult
sendMessage
(Message input, PipeLineSession session, ISender sender, Map<String, Object> threadContext) void
setAddInputToResult
(boolean b) Whentrue
the input is added to the result in an input elementvoid
setBlockSize
(int i) Controls multiline behaviour.protected void
setCloseIteratorOnExit
(boolean b) void
setCollectResults
(boolean b) Controls whether all the results of each iteration will be collected in one result message.void
setIgnoreExceptions
(boolean b) Whentrue
ignore any exception thrown by executing sendervoid
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.void
setMaxChildThreads
(int maxChildThreads) Maximum number of child threads that may run in parallel simultaneously (combined total of all threads calling this pipe).void
setMaxItems
(int maxItems) The maximum number of items returned.void
setNamespaceDefs
(String namespaceDefs) Namespace defintions for xpathExpression.void
setOmitXmlDeclaration
(boolean b) Force the transformer generated from the xpath-expression to omit the xml declarationvoid
setOutputType
(TransformerPool.OutputType outputType) Only valid for xpathexpressionvoid
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 returnedvoid
setRemoveDuplicates
(boolean b) Whentrue
duplicate input elements are removed, i.e. they are handled only oncevoid
setRemoveXmlDeclarationInResults
(boolean b) Postprocess each partial result, to remove the xml-declaration, as this is not allowed inside an xml-documentvoid
The sender that should send the messagevoid
Expression evaluated on each result and forwards to ["stopConditionMet"] forward if configured.void
setStyleSheetName
(String styleSheetName) Stylesheet to apply to each message, before sending itvoid
setTaskExecutor
(org.springframework.core.task.TaskExecutor taskExecutor) void
setXpathExpression
(String string) Alternatively: xpath-expression to create stylesheet fromMethods inherited from class org.frankframework.pipes.MessageSendingPipe
consumesSessionVariable, doPipe, getAuditTrailNamespaceDefs, getAuditTrailSessionKey, getAuditTrailXPath, getCheckRootTag, getConfigurationMetrics, getCorrelationIDNamespaceDefs, getCorrelationIDSessionKey, getCorrelationIDStyleSheet, getCorrelationIDXPath, getExceptionOnResult, getHideMethod, getInputValidator, getInputWrapper, getLabelNamespaceDefs, getLabelStyleSheet, getLabelXPath, getLinkMethod, getListener, getMaxRetries, getMessageLog, getOutputValidator, getOutputWrapper, getPresumedTimeOutInterval, getResultOnTimeOut, getRetryMaxInterval, getRetryMinInterval, getRetryNamespaceDefs, getRetryXPath, getSender, getStubFilename, getTimeoutOnResult, increaseRetryIntervalAndWait, isCheckXmlWellFormed, isUseInputForExtract, preserve, propagateName, setAuditTrailNamespaceDefs, setAuditTrailSessionKey, setAuditTrailXPath, setCheckRootTag, setCheckXmlWellFormed, setConfigurationMetrics, setCorrelationIDNamespaceDefs, setCorrelationIDSessionKey, setCorrelationIDStyleSheet, setCorrelationIDXPath, setExceptionOnResult, setHideMethod, setHideRegex, setInputValidator, setInputWrapper, setLabelNamespaceDefs, setLabelStyleSheet, setLabelXPath, setLinkMethod, setListener, setListenerProcessor, setMaxRetries, setMessageLog, setName, setOutputValidator, setOutputWrapper, setPipeProcessor, setPresumedTimeOutInterval, setResultOnTimeOut, setRetryMaxInterval, setRetryMinInterval, setRetryNamespaceDefs, setRetryXPath, setStubFilename, setTimeoutOnResult, setTimeOutOnResult, setUseInputForExtract, sizeStatisticsEnabled, start, stop
Methods inherited from class org.frankframework.pipes.FixedForwardPipe
getIfParam, getIfValue, getOnlyIfSessionKey, getOnlyIfValue, getParameterValue, getSuccessForward, getUnlessSessionKey, getUnlessValue, isSkipOnEmptyInput, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipe
Methods inherited from class org.frankframework.pipes.AbstractPipe
addParameter, createBean, findForward, getAdapter, getApplicationContext, getChompCharSize, getConfigurationClassLoader, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getEventSourceName, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getLocker, getLogIntermediaryResults, getMaxThreads, getName, getParameterList, getPipeLine, getSecLogSessionKeys, getStoreResultInSessionKey, hasRegisteredForward, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, registerForward, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setEventPublisher, setGetInputFromFixedValue, setGetInputFromSessionKey, setLocker, setLogIntermediaryResults, setMaxThreads, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, throwEvent
Methods inherited from class org.frankframework.core.TransactionAttributes
configureTransactionAttributes, getTransactionAttribute, getTransactionTimeout, getTxDef, isTransacted, isTransacted, setTransacted, setTransactionAttribute, setTransactionTimeout
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.frankframework.core.INamedObject
getName
Methods inherited from interface org.frankframework.core.IPipe
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:FixedForwardPipe
checks for correct configuration of forward- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIPipe
- Overrides:
configure
in classMessageSendingPipe
- 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
- 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:
sendMessage
in classMessageSendingPipe
- Throws:
SenderException
TimeoutException
IOException
-
getItem
- Throws:
SenderException
-
getStatisticsKeeper
@Nonnull protected io.micrometer.core.instrument.DistributionSummary getStatisticsKeeper(String name) -
setSender
Description copied from class:MessageSendingPipe
The sender that should send the message- Overrides:
setSender
in 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" can be configured to follow- Default value
- 0
-
setStopConditionXPathExpression
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, usemaxItems
. Previous versions documented thatposition()=2
could be used. This is not working as expected; Use maxItems instead -
setIgnoreExceptions
public void setIgnoreExceptions(boolean b) Whentrue
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 setfalse
, only a small summary is returned. Setting this attributes tofalse
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) Whentrue
the input is added to the result in an input element- Default value
- false
-
setRemoveDuplicates
public void setRemoveDuplicates(boolean b) Whentrue
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 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). Use0
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
-
getXpathExpression
-
getNamespaceDefs
-
getOutputType
-
isOmitXmlDeclaration
public boolean isOmitXmlDeclaration() -
getItemNoSessionKey
-
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)
-