Class AdvancedMessageSplitterService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.splitter.MessageSplitterServiceImp
-
- com.adaptris.core.services.splitter.AdvancedMessageSplitterService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,EventHandlerAware
,MessageEventGenerator
,Service
,ServiceWrapper
,StateManagedComponent
- Direct Known Subclasses:
PoolingMessageSplitterService
@ComponentProfile(summary="Split a message and execute an arbitary number of services on the split message", tag="service,splitter") public class AdvancedMessageSplitterService extends MessageSplitterServiceImp implements EventHandlerAware, ServiceWrapper
Splits incoming
AdaptrisMessage
s into several using an implementation ofMessageSplitter
.Rather than directly producing the message to a producer, this allows the use of a
ServiceCollection
as the target for the resulting split messages.In the adapter configuration file this class is aliased as advanced-message-splitter-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected EventHandler
eventHandler
-
Fields inherited from class com.adaptris.core.services.splitter.MessageSplitterServiceImp
KEY_CURRENT_SPLIT_MESSAGE_COUNT, KEY_SPLIT_MESSAGE_COUNT
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description AdvancedMessageSplitterService()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeService()
protected void
executeService(Service s, AdaptrisMessage msg)
java.lang.Boolean
getSendEvents()
Service
getService()
protected void
handleSplitMessage(AdaptrisMessage msg, java.util.function.Consumer<java.lang.Exception> callback)
protected void
initService()
void
prepare()
Prepare for initialisation.void
registerEventHandler(EventHandler eh)
Register the current event handler against this component.boolean
sendEvents()
protected void
sendEvents(AdaptrisMessage msg)
void
setSendEvents(java.lang.Boolean b)
Whether or not to send events for the message that has been split.void
setService(Service sc)
void
start()
Starts the component.void
stop()
Stop the componentService[]
wrappedServices()
Return all the services that are wrapped by this service.-
Methods inherited from class com.adaptris.core.services.splitter.MessageSplitterServiceImp
doService, getIgnoreSplitMessageFailures, getSplitter, ignoreSplitMessageFailures, setIgnoreSplitMessageFailures, setSplitter, waitForCompletion
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, doService, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Field Detail
-
eventHandler
protected transient EventHandler eventHandler
-
-
Method Detail
-
handleSplitMessage
protected void handleSplitMessage(AdaptrisMessage msg, java.util.function.Consumer<java.lang.Exception> callback) throws ServiceException
- Specified by:
handleSplitMessage
in classMessageSplitterServiceImp
- Throws:
ServiceException
-
executeService
protected void executeService(Service s, AdaptrisMessage msg) throws java.lang.Exception
- Throws:
java.lang.Exception
-
sendEvents
protected void sendEvents(AdaptrisMessage msg) throws CoreException
- Throws:
CoreException
-
initService
protected void initService() throws CoreException
- Overrides:
initService
in classMessageSplitterServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Overrides:
closeService
in classMessageSplitterServiceImp
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.start()
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classServiceImp
- See Also:
ComponentLifecycle.stop()
-
getService
public Service getService()
- Returns:
- the serviceList
-
setService
public void setService(Service sc)
- Parameters:
sc
- the serviceList to set
-
getSendEvents
public java.lang.Boolean getSendEvents()
- Returns:
- the sendEvents
-
sendEvents
public boolean sendEvents()
-
setSendEvents
public void setSendEvents(java.lang.Boolean b)
Whether or not to send events for the message that has been split.Note that even if this is set to true, because each child message has its own unique id, you will have to externally correlate the message lifecycle events together. Child messages will always have the metadata
CoreConstants.PARENT_UNIQUE_ID_KEY
set with the originating message id.- Parameters:
b
- true to send events (default false)
-
registerEventHandler
public void registerEventHandler(EventHandler eh)
Description copied from interface:EventHandlerAware
Register the current event handler against this component.- Specified by:
registerEventHandler
in interfaceEventHandlerAware
- Parameters:
eh
- the event handler currently in use.- See Also:
EventHandlerAware.registerEventHandler(com.adaptris.core.EventHandler)
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
wrappedServices
public Service[] wrappedServices()
Description copied from interface:ServiceWrapper
Return all the services that are wrapped by this service.- Specified by:
wrappedServices
in interfaceServiceWrapper
- Returns:
- an array of wrapped services.
-
-