@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
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.
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 and Description |
---|
ForEach() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
ThenService |
getThen()
Get the for-each-then service.
|
java.lang.Integer |
getThreadCount()
Get the number of threads to use.
|
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setThen(ThenService thenService)
Set the for-each-then service.
|
void |
setThreadCount(java.lang.Integer threadCount)
Set the number of threads to use.
|
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
public ThenService getThen()
public void setThen(ThenService thenService)
thenService
- The service.public java.lang.Integer getThreadCount()
public void setThreadCount(java.lang.Integer threadCount)
threadCount
- The number of threads.public void doService(AdaptrisMessage msg) throws ServiceException
Apply the service to the message.
.msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
sprotected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
CoreException
public void start() throws CoreException
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface ComponentLifecycle
start
in class ServiceImp
CoreException
- wrapping any underlying Exception
spublic void stop()
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
stop
in interface ComponentLifecycle
stop
in class ServiceImp