Package com.adaptris.core
Class WorkflowWithObjectPool
- java.lang.Object
-
- com.adaptris.core.WorkflowImp
-
- com.adaptris.core.WorkflowWithObjectPool
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageListener
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,EventHandlerAware
,StateManagedComponent
,Workflow
- Direct Known Subclasses:
PoolingWorkflow
,ThreadContextWorkflow
public abstract class WorkflowWithObjectPool extends WorkflowImp
A Workflow that has a object pool of ServiceCollections
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
WorkflowWithObjectPool.Worker
protected class
WorkflowWithObjectPool.WorkerFactory
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_IDLE
The default max idle size.static int
DEFAULT_MAX_POOLSIZE
The default maximum pool size.static int
DEFAULT_MIN_IDLE
the default minimum idle size.-
Fields inherited from class com.adaptris.core.WorkflowImp
eventHandler, log, startTime, stopTime
-
Fields inherited from interface com.adaptris.core.Workflow
PREVIOUS_GUID_KEY, WORKFLOW_ID_KEY
-
-
Constructor Summary
Constructors Constructor Description WorkflowWithObjectPool()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkPoolConfig()
Check the object pool such that it isn't going to cause issues.protected ServiceCollection
cloneServiceCollection(ServiceCollection original)
protected org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker>
createObjectPool()
TimeInterval
getInitWaitTime()
Set the amount of time to wait for object pool population.java.lang.Integer
getMaxIdle()
The maximum number of idle objects in the pool.java.lang.Integer
getMinIdle()
The minimum number of idle objects in the pool.java.lang.Integer
getPoolSize()
The max size of the poollong
initWaitTimeMs()
int
maxIdle()
Return the maximum idle objects in the pool.int
minIdle()
Return the maximum idle objects in the pool.void
onAdaptrisMessage(AdaptrisMessage msg, java.util.function.Consumer<AdaptrisMessage> success, java.util.function.Consumer<AdaptrisMessage> failure)
Process a message from theMessageConsumer
protected abstract void
onMessage(AdaptrisMessage msg)
int
poolSize()
protected org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker>
populatePool(org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker> objectPool)
protected void
preFlightServiceCheck()
protected void
prepareWorkflow()
protected void
resubmitMessage(AdaptrisMessage msg)
Resubmit a message upon the channel becoming available again.protected void
returnObject(org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker> pool, WorkflowWithObjectPool.Worker worker)
void
setInitWaitTime(TimeInterval initWaitTime)
Set the amount of time to wait for object pool population.void
setMaxIdle(java.lang.Integer maxIdle)
The maximum number of idle objects in the pool.void
setMinIdle(java.lang.Integer minIdle)
The minimum number of idle objects in the pool.void
setPoolSize(java.lang.Integer poolSize)
The max size of the pool-
Methods inherited from class com.adaptris.core.WorkflowImp
addConsumeLocation, addInterceptor, changeState, channelUnavailableWait, close, closeWorkflow, copyExceptionHeaders, disableMessageCount, doProduce, friendlyName, getChannelUnavailableWaitInterval, getComments, getConsumer, getDisableDefaultMessageCount, getInterceptors, getMessageErrorHandler, getMessageLogger, getProduceExceptionHandler, getProducer, getSendEvents, getServiceCollection, getUniqueId, handleBadMessage, handleBadMessage, handleChannelUnavailable, handleProduceException, init, initialiseWorkflow, lastStartTime, lastStopTime, logSuccess, messageLogger, obtainChannel, obtainWorkflowId, prepare, processingStart, registerActiveMsgErrorHandler, registerChannel, registerEventHandler, requestClose, requestInit, requestStart, requestStop, retrieveActiveMsgErrorHandler, retrieveComponentState, sendEvents, sendMessageLifecycleEvent, setChannelUnavailableWaitInterval, setComments, setConsumer, setDisableDefaultMessageCount, setInterceptors, setMessageErrorHandler, setMessageLogger, setProduceExceptionHandler, setProducer, setSendEvents, setServiceCollection, setUniqueId, start, startWorkflow, stop, stopWorkflow, workflowEnd, workflowStart
-
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.AdaptrisMessageListener
onAdaptrisMessage, onAdaptrisMessage
-
-
-
-
Field Detail
-
DEFAULT_MAX_POOLSIZE
public static final int DEFAULT_MAX_POOLSIZE
The default maximum pool size.- See Also:
- Constant Field Values
-
DEFAULT_MIN_IDLE
public static final int DEFAULT_MIN_IDLE
the default minimum idle size.- See Also:
- Constant Field Values
-
DEFAULT_MAX_IDLE
public static final int DEFAULT_MAX_IDLE
The default max idle size.- See Also:
- Constant Field Values
-
-
Method Detail
-
onAdaptrisMessage
public void onAdaptrisMessage(AdaptrisMessage msg, java.util.function.Consumer<AdaptrisMessage> success, java.util.function.Consumer<AdaptrisMessage> failure)
Process a message from theMessageConsumer
- Parameters:
msg
- the messagesuccess
- called on successfailure
- called on failure- See Also:
WorkflowImp.handleBadMessage(AdaptrisMessage)
-
onMessage
protected abstract void onMessage(AdaptrisMessage msg)
-
resubmitMessage
protected void resubmitMessage(AdaptrisMessage msg)
Description copied from class:WorkflowImp
Resubmit a message upon the channel becoming available again.- Specified by:
resubmitMessage
in classWorkflowImp
- Parameters:
msg
- the AdaptrisMessage.
-
poolSize
public int poolSize()
-
preFlightServiceCheck
protected void preFlightServiceCheck() throws CoreException
- Throws:
CoreException
-
checkPoolConfig
protected void checkPoolConfig()
Check the object pool such that it isn't going to cause issues.
-
createObjectPool
protected org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker> createObjectPool() throws CoreException
- Throws:
CoreException
-
populatePool
protected org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker> populatePool(org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker> objectPool) throws CoreException
- Throws:
CoreException
-
minIdle
public int minIdle()
Return the maximum idle objects in the pool.- Returns:
- the maximum idle number
-
maxIdle
public int maxIdle()
Return the maximum idle objects in the pool.- Returns:
- the maximum idle number
-
initWaitTimeMs
public long initWaitTimeMs()
-
cloneServiceCollection
protected ServiceCollection cloneServiceCollection(ServiceCollection original) throws CoreException
- Throws:
CoreException
-
returnObject
protected void returnObject(org.apache.commons.pool2.ObjectPool<WorkflowWithObjectPool.Worker> pool, WorkflowWithObjectPool.Worker worker)
-
prepareWorkflow
protected void prepareWorkflow() throws CoreException
- Specified by:
prepareWorkflow
in classWorkflowImp
- Throws:
CoreException
-
getPoolSize
public java.lang.Integer getPoolSize()
The max size of the pool
-
setPoolSize
public void setPoolSize(java.lang.Integer poolSize)
The max size of the pool
-
getMinIdle
public java.lang.Integer getMinIdle()
The minimum number of idle objects in the pool.
-
setMinIdle
public void setMinIdle(java.lang.Integer minIdle)
The minimum number of idle objects in the pool.
-
getMaxIdle
public java.lang.Integer getMaxIdle()
The maximum number of idle objects in the pool.
-
setMaxIdle
public void setMaxIdle(java.lang.Integer maxIdle)
The maximum number of idle objects in the pool.
-
getInitWaitTime
public TimeInterval getInitWaitTime()
Set the amount of time to wait for object pool population.Upon start the object pool is populated with the
minIdle()
number of workers.
-
setInitWaitTime
public void setInitWaitTime(TimeInterval initWaitTime)
Set the amount of time to wait for object pool population.Upon start the object pool is populated with the
minIdle()
number of workers.
-
-