Class PoolingMessageSplitterService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.splitter.MessageSplitterServiceImp
-
- com.adaptris.core.services.splitter.AdvancedMessageSplitterService
-
- com.adaptris.core.services.splitter.PoolingMessageSplitterService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,EventHandlerAware
,MessageEventGenerator
,Service
,ServiceWrapper
,StateManagedComponent
@ComponentProfile(summary="Split a message and execute an arbitary number of services on the split message", tag="service,splitter", since="3.7.1") public class PoolingMessageSplitterService extends AdvancedMessageSplitterService
Extension toAdvancedMessageSplitterService
that uses a underlying thread and object pool to execute the service on each split message.Note that using this splitter may mean that messages become un-ordered; if the order of the split messages is critical, then you probably shouldn't use this service. Additionally, individual split-message failures will only be reported on after all the split messages have been processed, so unlike
AdvancedMessageSplitterService
;MessageSplitterServiceImp.setIgnoreSplitMessageFailures(Boolean)
will not halt the processing of the subsequent split messagesIn the adapter configuration file this class is aliased as pooling-message-splitter-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.splitter.AdvancedMessageSplitterService
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 PoolingMessageSplitterService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeService()
java.lang.Integer
getMaxThreads()
Set the max number of threads to operate on split messagesjava.lang.Boolean
getWaitWhileBusy()
Actively check if the underlying object pool is ready to accept more workers.java.lang.Boolean
getWarmStart()
Specify if the underlying object pool should be warmed up onstart()
.protected void
handleSplitMessage(AdaptrisMessage msg, java.util.function.Consumer<java.lang.Exception> callback)
protected void
initService()
void
setMaxThreads(java.lang.Integer maxThreads)
Set the max number of threads to operate on split messagesvoid
setWaitWhileBusy(java.lang.Boolean waitWhileBusy)
Actively check if the underlying object pool is ready to accept more workers.void
setWarmStart(java.lang.Boolean warmStart)
Specify if the underlying object pool should be warmed up onstart()
.void
start()
Starts the component.protected void
waitQuietly(java.lang.Object monitor)
PoolingMessageSplitterService
withMaxThreads(java.lang.Integer i)
PoolingMessageSplitterService
withWaitWhileBusy(java.lang.Boolean b)
PoolingMessageSplitterService
withWarmStart(java.lang.Boolean b)
-
Methods inherited from class com.adaptris.core.services.splitter.AdvancedMessageSplitterService
executeService, getSendEvents, getService, prepare, registerEventHandler, sendEvents, sendEvents, setSendEvents, setService, stop, wrappedServices
-
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
-
-
-
-
Method Detail
-
handleSplitMessage
protected void handleSplitMessage(AdaptrisMessage msg, java.util.function.Consumer<java.lang.Exception> callback) throws ServiceException
- Overrides:
handleSplitMessage
in classAdvancedMessageSplitterService
- Throws:
ServiceException
-
initService
protected void initService() throws CoreException
- Overrides:
initService
in classAdvancedMessageSplitterService
- Throws:
CoreException
-
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 classAdvancedMessageSplitterService
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.start()
-
closeService
protected void closeService()
- Overrides:
closeService
in classAdvancedMessageSplitterService
-
withWarmStart
public PoolingMessageSplitterService withWarmStart(java.lang.Boolean b)
-
withMaxThreads
public PoolingMessageSplitterService withMaxThreads(java.lang.Integer i)
-
withWaitWhileBusy
public PoolingMessageSplitterService withWaitWhileBusy(java.lang.Boolean b)
-
waitQuietly
protected void waitQuietly(java.lang.Object monitor)
-
getMaxThreads
public java.lang.Integer getMaxThreads()
Set the max number of threads to operate on split messagesThe default is 10 if not explicitly specified
-
setMaxThreads
public void setMaxThreads(java.lang.Integer maxThreads)
Set the max number of threads to operate on split messagesThe default is 10 if not explicitly specified
-
getWarmStart
public java.lang.Boolean getWarmStart()
Specify if the underlying object pool should be warmed up onstart()
.The default is false if not specified
-
setWarmStart
public void setWarmStart(java.lang.Boolean warmStart)
Specify if the underlying object pool should be warmed up onstart()
.The default is false if not specified
-
getWaitWhileBusy
public java.lang.Boolean getWaitWhileBusy()
Actively check if the underlying object pool is ready to accept more workers.If set to true, then we check that the underlying object pool has enough space for us to submit more jobs. This means that if you have a large number of split messages, then we don't attempt to flood the queue with thousands of messages causing possible issues within constrained environments. It defaults to false if not explicitly specified, and if set to true will have a small negative impact on performance.
-
setWaitWhileBusy
public void setWaitWhileBusy(java.lang.Boolean waitWhileBusy)
Actively check if the underlying object pool is ready to accept more workers.If set to true, then we check that the underlying object pool has enough space for us to submit more jobs. This means that if you have a large number of split messages, then we don't attempt to flood the queue with thousands of messages causing possible issues within constrained environments. It defaults to false if not explicitly specified, and if set to true will have a small negative impact on performance.
-
-