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, ServiceWrapperSplits incoming
AdaptrisMessages into several using an implementation ofMessageSplitter.Rather than directly producing the message to a producer, this allows the use of a
ServiceCollectionas 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 EventHandlereventHandler-
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 voidcloseService()protected voidexecuteService(Service s, AdaptrisMessage msg)java.lang.BooleangetSendEvents()ServicegetService()protected voidhandleSplitMessage(AdaptrisMessage msg, java.util.function.Consumer<java.lang.Exception> callback)protected voidinitService()voidprepare()Prepare for initialisation.voidregisterEventHandler(EventHandler eh)Register the current event handler against this component.booleansendEvents()protected voidsendEvents(AdaptrisMessage msg)voidsetSendEvents(java.lang.Boolean b)Whether or not to send events for the message that has been split.voidsetService(Service sc)voidstart()Starts the component.voidstop()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:
handleSplitMessagein 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:
initServicein classMessageSplitterServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Overrides:
closeServicein classMessageSplitterServiceImp
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts 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:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
ComponentLifecycle.start()
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop 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 aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin 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_KEYset with the originating message id.- Parameters:
b- true to send events (default false)
-
registerEventHandler
public void registerEventHandler(EventHandler eh)
Description copied from interface:EventHandlerAwareRegister the current event handler against this component.- Specified by:
registerEventHandlerin interfaceEventHandlerAware- Parameters:
eh- the event handler currently in use.- See Also:
EventHandlerAware.registerEventHandler(com.adaptris.core.EventHandler)
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
wrappedServices
public Service[] wrappedServices()
Description copied from interface:ServiceWrapperReturn all the services that are wrapped by this service.- Specified by:
wrappedServicesin interfaceServiceWrapper- Returns:
- an array of wrapped services.
-
-