@ComponentProfile(summary="Split a message and then execute the associated services on the split items, aggregating the split messages afterwards", tag="service,splitjoin") public class SplitJoinService extends ServiceImp implements EventHandlerAware, ServiceWrapper
This service splits a message according to the configured MessageSplitter
implementation, executes the configured
Service
and subsequently joins all the messages back using the configured MessageAggregator
implementation
A new (cloned) instance of the underlying Service
is created for every split message, and executed in
its own thread; this means that where there is a high cost of initialisation for the service, then you may get better performance
aggregating the messages in a different way.
In the adapter configuration file this class is aliased as split-join-service which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
SplitJoinService() |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<java.util.concurrent.Callable<AdaptrisMessage>> |
buildTasks(ServiceExceptionHandler handler,
java.util.List<AdaptrisMessage> msgs) |
protected void |
closeService() |
protected java.util.concurrent.ExecutorService |
createExecutor() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
MessageAggregator |
getAggregator() |
Service |
getService() |
MessageSplitter |
getSplitter() |
TimeInterval |
getTimeout() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
registerEventHandler(EventHandler eh)
Register the current event handler against this component.
|
void |
setAggregator(MessageAggregator mj)
The
MessageAggregator implementation to use to join messages together. |
void |
setExceptionStrategy(PoolingFutureExceptionStrategy exceptionStrategy)
The
PoolingFutureExceptionStrategy implementation to use to handle task exceptions. |
void |
setService(Service s)
The
Service to execute over all the split messages. |
void |
setSplitter(MessageSplitter ms)
The
MessageSplitter implementation to use to split the incoming message. |
void |
setTimeout(TimeInterval ttl)
Set the maximum amount of time to wait for all the instances of services to complete.
|
Service[] |
wrappedServices()
Return all the services that are wrapped by this service.
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsConfirmation, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isConfirmation, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, rethrowServiceException, retrieveComponentState, setContinueOnFail, setIsConfirmation, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
continueOnFailure, isBranching, setUniqueId
createName, createQualifier, isConfirmation, isTrackingEndpoint
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
getUniqueId
close, init, start, stop
getLookupName
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
doService
in interface Service
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
sprotected java.util.List<java.util.concurrent.Callable<AdaptrisMessage>> buildTasks(ServiceExceptionHandler handler, java.util.List<AdaptrisMessage> msgs) throws java.lang.Exception
java.lang.Exception
protected java.util.concurrent.ExecutorService createExecutor()
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
public TimeInterval getTimeout()
public void setTimeout(TimeInterval ttl)
If the time to live is exceeded then an exception will be thrown by the service
ttl
- the timeout to set, default is 10 minutespublic void registerEventHandler(EventHandler eh)
EventHandlerAware
registerEventHandler
in interface EventHandlerAware
eh
- the event handler currently in use.public Service getService()
public void setService(Service s)
Service
to execute over all the split messages.s
- the service to setpublic MessageSplitter getSplitter()
public void setSplitter(MessageSplitter ms)
MessageSplitter
implementation to use to split the incoming message.ms
- the messageSplitter to setpublic MessageAggregator getAggregator()
public void setAggregator(MessageAggregator mj)
MessageAggregator
implementation to use to join messages together.mj
- the messageJoiner to setpublic Service[] wrappedServices()
ServiceWrapper
wrappedServices
in interface ServiceWrapper
public void setExceptionStrategy(PoolingFutureExceptionStrategy exceptionStrategy)
PoolingFutureExceptionStrategy
implementation to use to handle task exceptions.exceptionStrategy
-