public class Foreach extends AbstractMessageProcessorOwner implements Initialisable, MessageProcessor, NonBlockingSupported
Foreach
MessageProcessor allows iterating over a collection payload, or any collection
obtained by an expression, generating a message for each element.
The number of the message being processed is stored in #[variable:counter]
and the root
message is store in #[variable:rootMessage]
. Both variables may be renamed by means of
setCounterVariableName(String)
and setRootMessageVariableName(String)
.
Defining a groupSize greater than one, allows iterating over collections of elements of the specified size.
The MuleEvent
sent to the next message processor is the same that arrived to foreach.
Modifier and Type | Field and Description |
---|---|
static String |
COUNTER_PROPERTY |
protected Log |
logger |
static String |
ROOT_MESSAGE_PROPERTY |
flowConstruct, messagingExceptionHandler, muleContext
PHASE_NAME
PHASE_NAME
PHASE_NAME
PHASE_NAME
PROPERTY_NAME
Constructor and Description |
---|
Foreach() |
Modifier and Type | Method and Description |
---|---|
void |
addMessageProcessorPathElements(MessageProcessorPathElement pathElement)
Add the child nodes to the path element tree.
|
protected void |
doProcess(MuleEvent event) |
protected List<MessageProcessor> |
getOwnedMessageProcessors() |
void |
initialise()
Method used to perform any initialisation work.
|
MuleEvent |
process(MuleEvent event)
Invokes the MessageProcessor.
|
void |
setBatchSize(int batchSize) |
void |
setCollectionExpression(String expression) |
void |
setCounterVariableName(String counterVariableName) |
void |
setMessageProcessors(List<MessageProcessor> messageProcessors) |
void |
setRootMessageVariableName(String rootMessageVariableName) |
getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
dispose, getFlowConstruct, getMessagingExceptionHandler, getMuleContext, setFlowConstruct, setMessagingExceptionHandler, setMuleContext, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dispose
setMuleContext
setFlowConstruct
public static final String ROOT_MESSAGE_PROPERTY
public static final String COUNTER_PROPERTY
protected Log logger
public MuleEvent process(MuleEvent event) throws MuleException
MessageProcessor
process
in interface MessageProcessor
event
- MuleEvent to be processedMuleException
protected void doProcess(MuleEvent event) throws MuleException, MessagingException
MuleException
MessagingException
protected List<MessageProcessor> getOwnedMessageProcessors()
getOwnedMessageProcessors
in class AbstractMessageProcessorOwner
public void addMessageProcessorPathElements(MessageProcessorPathElement pathElement)
MessageProcessorContainer
addMessageProcessorPathElements
in interface MessageProcessorContainer
addMessageProcessorPathElements
in class AbstractMessageProcessorOwner
public void setMessageProcessors(List<MessageProcessor> messageProcessors) throws MuleException
MuleException
public void initialise() throws InitialisationException
Initialisable
InitialisationException
should be thrown,
causing the Mule instance to shutdown. If the error is recoverable, say by
retrying to connect, a RecoverableException
should be thrown.
There is no guarantee that by throwing a Recoverable exception that the Mule
instance will not shut down.initialise
in interface Initialisable
initialise
in class AbstractMuleObjectOwner<MessageProcessor>
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdownRecoverableException
- if an error occurs that can be recovered frompublic void setCollectionExpression(String expression)
public void setBatchSize(int batchSize)
public void setRootMessageVariableName(String rootMessageVariableName)
public void setCounterVariableName(String counterVariableName)
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.