Class ScheduledMessageProcessor
- java.lang.Object
-
- org.apache.synapse.message.processor.impl.AbstractMessageProcessor
-
- org.apache.synapse.message.processor.impl.ScheduledMessageProcessor
-
- All Implemented Interfaces:
ManagedLifecycle,MessageProcessor,Nameable,SynapseArtifact,org.apache.synapse.task.TaskManagerObserver
- Direct Known Subclasses:
FailoverScheduledMessageForwardingProcessor,SamplingProcessor,ScheduledMessageForwardingProcessor
public abstract class ScheduledMessageProcessor extends AbstractMessageProcessor implements org.apache.synapse.task.TaskManagerObserver
Implements the common message processor infrastructure which is used by the bothForwardingandSamplingmessage Processors. Mainly responsible for handling life cycle states of the message processors. Some of the well known life cycle states arestart,pause,destroy,deactivateetc.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcronExpressionA cron expression to run the samplerprotected longintervalThe interval at which this processor runs , default value is 1000msprotected String[]nonRetryStatusCodesThis is specially used for REST scenarios where http status codes can take semantics in a RESTful architecture.protected BlockingMsgSendersenderprotected SynapseEnvironmentsynapseEnvironment-
Fields inherited from class org.apache.synapse.message.processor.impl.AbstractMessageProcessor
artifactContainerName, configuration, description, fileName, isEdited, messageConsumers, messageStore, name, parameters, targetEndpoint
-
-
Constructor Summary
Constructors Constructor Description ScheduledMessageProcessor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanactivate()This method is used to activate a deactivated message processor.voidcleanUpDeactivatedProcessors()Execute clean up tasks of a message processor which were deactivated remotely in cluster modevoidcleanupLocalResources()This method is used to cleanup local resources such as JMS connections used by the message processor.booleandeactivate()This method is used to deactivate the message processor.voiddestroy()This method should implement the destroying of the implemented parts of the configuration.voiddestroy(boolean preserveState)Undeploy the artifact but keeps the current state based on the preserveState argument.voiddestroy(boolean preserveState, boolean isArtifactUpdate)Destroy the artifacts.booleangetActivated()booleangetIsActivatedParamValue()protected abstract org.apache.synapse.task.TaskgetTask()Gives theTaskinstance associated with this processor.voidinit(SynapseEnvironment se)This method should implement the initialization of the implemented parts of the configuration.booleanisActive()booleanisDeactivated()This method is used to see if the message processor is deactivated.booleanisPaused()This method is used to check if the state is in paused mode.protected booleanisProcessorStartAsDeactivated()booleanisTaskLocationKnown()protected booleanisThrottling(long interval)nTask does not except values less than 1000 for its schedule interval.booleanisThrottling(String cronExpression)voidpauseService()This method is only used by the associated forwarding services of message processors.voidresumeRemotely()Execute resume tasks of a message processor in cluster modevoidresumeService()This is the opposite of pauseService method.voidsetParameters(Map<String,Object> parameters)This method is used to set configuration parameters of the message processor.booleanstart()This method is used to start the message processor.booleanstop()This method is used to stop the message processor.voidupdate()-
Methods inherited from class org.apache.synapse.message.processor.impl.AbstractMessageProcessor
getArtifactContainerName, getDescription, getFileName, getMessageConsumer, getMessageStoreName, getName, getParameters, getTargetEndpoint, isEdited, setArtifactContainerName, setDescription, setFileName, setIsEdited, setMessageConsumer, setMessageStoreName, setName, setTargetEndpoint
-
-
-
-
Field Detail
-
interval
protected long interval
The interval at which this processor runs , default value is 1000ms
-
cronExpression
protected String cronExpression
A cron expression to run the sampler
-
nonRetryStatusCodes
protected String[] nonRetryStatusCodes
This is specially used for REST scenarios where http status codes can take semantics in a RESTful architecture.
-
sender
protected BlockingMsgSender sender
-
synapseEnvironment
protected SynapseEnvironment synapseEnvironment
-
-
Method Detail
-
init
public void init(SynapseEnvironment se)
Description copied from interface:ManagedLifecycleThis method should implement the initialization of the implemented parts of the configuration.- Specified by:
initin interfaceManagedLifecycle- Overrides:
initin classAbstractMessageProcessor- Parameters:
se- SynapseEnvironment to be used for initialization
-
getIsActivatedParamValue
public boolean getIsActivatedParamValue()
-
isProcessorStartAsDeactivated
protected boolean isProcessorStartAsDeactivated()
-
start
public boolean start()
Description copied from interface:MessageProcessorThis method is used to start the message processor. Once the message processor is started it will start receiving messages- Specified by:
startin interfaceMessageProcessor- Returns:
trueif successful,falseotherwise
-
isDeactivated
public boolean isDeactivated()
Description copied from interface:MessageProcessorThis method is used to see if the message processor is deactivated.- Specified by:
isDeactivatedin interfaceMessageProcessor- Returns:
trueif successful,falseotherwise
-
setParameters
public void setParameters(Map<String,Object> parameters)
Description copied from interface:MessageProcessorThis method is used to set configuration parameters of the message processor. For example, triggering interval retrying interval, and etc.- Specified by:
setParametersin interfaceMessageProcessor- Overrides:
setParametersin classAbstractMessageProcessor- Parameters:
parameters- Message processor parameters.
-
stop
public boolean stop()
Description copied from interface:MessageProcessorThis method is used to stop the message processor. Once the the message processor is stopped it will no longer receive messages. A stopped message processor cannot re restarted without re-instantiating.- Specified by:
stopin interfaceMessageProcessor- Returns:
trueif successful,falseotherwise
-
destroy
public void destroy()
Description copied from interface:ManagedLifecycleThis method should implement the destroying of the implemented parts of the configuration.- Specified by:
destroyin interfaceManagedLifecycle
-
destroy
public void destroy(boolean preserveState)
Description copied from class:AbstractMessageProcessorUndeploy the artifact but keeps the current state based on the preserveState argument. if true keep the current state, else remove the state as well as the artifact.- Overrides:
destroyin classAbstractMessageProcessor- Parameters:
preserveState- determine whether to preserve the artifacts state or not
-
destroy
public void destroy(boolean preserveState, boolean isArtifactUpdate)Description copied from class:AbstractMessageProcessorDestroy the artifacts.- Overrides:
destroyin classAbstractMessageProcessor- Parameters:
preserveState- whether to preserve state in registry.isArtifactUpdate- whether this is triggered in artifact update flow.
-
deactivate
public boolean deactivate()
Description copied from interface:MessageProcessorThis method is used to deactivate the message processor. This will temporarily halt executing services.- Specified by:
deactivatein interfaceMessageProcessor- Returns:
trueif successful,falseotherwise
-
activate
public boolean activate()
Description copied from interface:MessageProcessorThis method is used to activate a deactivated message processor. Activating message processor will cause the services to start- Specified by:
activatein interfaceMessageProcessor- Returns:
trueif successful,falseotherwise
-
pauseService
public void pauseService()
Description copied from interface:MessageProcessorThis method is only used by the associated forwarding services of message processors. When the service fails to send the message to the backend it pauses the message processor and starts retrying. Pausing the message processor avoids re-triggering new services till the existing service succeed.- Specified by:
pauseServicein interfaceMessageProcessor
-
resumeService
public void resumeService()
Description copied from interface:MessageProcessorThis is the opposite of pauseService method. This method resumes a paused method.- Specified by:
resumeServicein interfaceMessageProcessor
-
isActive
public boolean isActive()
-
isTaskLocationKnown
public boolean isTaskLocationKnown()
-
isPaused
public boolean isPaused()
Description copied from interface:MessageProcessorThis method is used to check if the state is in paused mode.- Specified by:
isPausedin interfaceMessageProcessor- Returns:
- returns true on success.
-
getActivated
public boolean getActivated()
-
isThrottling
protected boolean isThrottling(long interval)
nTask does not except values less than 1000 for its schedule interval. Therefore when the interval is less than 1000 ms we have to handle it as a separate case.- Parameters:
interval- in which scheduler triggers its job.- Returns:
- true if it needs to run on throttle mode,
falseotherwise.
-
isThrottling
public boolean isThrottling(String cronExpression)
-
getTask
protected abstract org.apache.synapse.task.Task getTask()
Gives theTaskinstance associated with this processor.- Returns:
Taskassociated with this processor.
-
update
public void update()
- Specified by:
updatein interfaceorg.apache.synapse.task.TaskManagerObserver
-
cleanupLocalResources
public void cleanupLocalResources()
Description copied from interface:MessageProcessorThis method is used to cleanup local resources such as JMS connections used by the message processor.- Specified by:
cleanupLocalResourcesin interfaceMessageProcessor
-
cleanUpDeactivatedProcessors
public void cleanUpDeactivatedProcessors()
Description copied from interface:MessageProcessorExecute clean up tasks of a message processor which were deactivated remotely in cluster mode- Specified by:
cleanUpDeactivatedProcessorsin interfaceMessageProcessor
-
resumeRemotely
public void resumeRemotely()
Description copied from interface:MessageProcessorExecute resume tasks of a message processor in cluster mode- Specified by:
resumeRemotelyin interfaceMessageProcessor
-
-