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 bothForwarding
andSampling
message Processors. Mainly responsible for handling life cycle states of the message processors. Some of the well known life cycle states arestart
,pause
,destroy
,deactivate
etc.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
cronExpression
A cron expression to run the samplerprotected long
interval
The interval at which this processor runs , default value is 1000msprotected String[]
nonRetryStatusCodes
This is specially used for REST scenarios where http status codes can take semantics in a RESTful architecture.protected BlockingMsgSender
sender
protected SynapseEnvironment
synapseEnvironment
-
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 boolean
activate()
This method is used to activate a deactivated message processor.void
cleanUpDeactivatedProcessors()
Execute clean up tasks of a message processor which were deactivated remotely in cluster modevoid
cleanupLocalResources()
This method is used to cleanup local resources such as JMS connections used by the message processor.boolean
deactivate()
This method is used to deactivate the message processor.void
destroy()
This method should implement the destroying of the implemented parts of the configuration.void
destroy(boolean preserveState)
Undeploy the artifact but keeps the current state based on the preserveState argument.void
destroy(boolean preserveState, boolean isArtifactUpdate)
Destroy the artifacts.boolean
getActivated()
boolean
getIsActivatedParamValue()
protected abstract org.apache.synapse.task.Task
getTask()
Gives theTask
instance associated with this processor.void
init(SynapseEnvironment se)
This method should implement the initialization of the implemented parts of the configuration.boolean
isActive()
boolean
isDeactivated()
This method is used to see if the message processor is deactivated.boolean
isPaused()
This method is used to check if the state is in paused mode.protected boolean
isProcessorStartAsDeactivated()
boolean
isTaskLocationKnown()
protected boolean
isThrottling(long interval)
nTask does not except values less than 1000 for its schedule interval.boolean
isThrottling(String cronExpression)
void
pauseService()
This method is only used by the associated forwarding services of message processors.void
resumeRemotely()
Execute resume tasks of a message processor in cluster modevoid
resumeService()
This is the opposite of pauseService method.void
setParameters(Map<String,Object> parameters)
This method is used to set configuration parameters of the message processor.boolean
start()
This method is used to start the message processor.boolean
stop()
This method is used to stop the message processor.void
update()
-
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:ManagedLifecycle
This method should implement the initialization of the implemented parts of the configuration.- Specified by:
init
in interfaceManagedLifecycle
- Overrides:
init
in 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:MessageProcessor
This method is used to start the message processor. Once the message processor is started it will start receiving messages- Specified by:
start
in interfaceMessageProcessor
- Returns:
true
if successful,false
otherwise
-
isDeactivated
public boolean isDeactivated()
Description copied from interface:MessageProcessor
This method is used to see if the message processor is deactivated.- Specified by:
isDeactivated
in interfaceMessageProcessor
- Returns:
true
if successful,false
otherwise
-
setParameters
public void setParameters(Map<String,Object> parameters)
Description copied from interface:MessageProcessor
This method is used to set configuration parameters of the message processor. For example, triggering interval retrying interval, and etc.- Specified by:
setParameters
in interfaceMessageProcessor
- Overrides:
setParameters
in classAbstractMessageProcessor
- Parameters:
parameters
- Message processor parameters.
-
stop
public boolean stop()
Description copied from interface:MessageProcessor
This 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:
stop
in interfaceMessageProcessor
- Returns:
true
if successful,false
otherwise
-
destroy
public void destroy()
Description copied from interface:ManagedLifecycle
This method should implement the destroying of the implemented parts of the configuration.- Specified by:
destroy
in interfaceManagedLifecycle
-
destroy
public void destroy(boolean preserveState)
Description copied from class:AbstractMessageProcessor
Undeploy 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:
destroy
in classAbstractMessageProcessor
- Parameters:
preserveState
- determine whether to preserve the artifacts state or not
-
destroy
public void destroy(boolean preserveState, boolean isArtifactUpdate)
Description copied from class:AbstractMessageProcessor
Destroy the artifacts.- Overrides:
destroy
in 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:MessageProcessor
This method is used to deactivate the message processor. This will temporarily halt executing services.- Specified by:
deactivate
in interfaceMessageProcessor
- Returns:
true
if successful,false
otherwise
-
activate
public boolean activate()
Description copied from interface:MessageProcessor
This method is used to activate a deactivated message processor. Activating message processor will cause the services to start- Specified by:
activate
in interfaceMessageProcessor
- Returns:
true
if successful,false
otherwise
-
pauseService
public void pauseService()
Description copied from interface:MessageProcessor
This 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:
pauseService
in interfaceMessageProcessor
-
resumeService
public void resumeService()
Description copied from interface:MessageProcessor
This is the opposite of pauseService method. This method resumes a paused method.- Specified by:
resumeService
in interfaceMessageProcessor
-
isActive
public boolean isActive()
-
isTaskLocationKnown
public boolean isTaskLocationKnown()
-
isPaused
public boolean isPaused()
Description copied from interface:MessageProcessor
This method is used to check if the state is in paused mode.- Specified by:
isPaused
in 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,
false
otherwise.
-
isThrottling
public boolean isThrottling(String cronExpression)
-
getTask
protected abstract org.apache.synapse.task.Task getTask()
Gives theTask
instance associated with this processor.- Returns:
Task
associated with this processor.
-
update
public void update()
- Specified by:
update
in interfaceorg.apache.synapse.task.TaskManagerObserver
-
cleanupLocalResources
public void cleanupLocalResources()
Description copied from interface:MessageProcessor
This method is used to cleanup local resources such as JMS connections used by the message processor.- Specified by:
cleanupLocalResources
in interfaceMessageProcessor
-
cleanUpDeactivatedProcessors
public void cleanUpDeactivatedProcessors()
Description copied from interface:MessageProcessor
Execute clean up tasks of a message processor which were deactivated remotely in cluster mode- Specified by:
cleanUpDeactivatedProcessors
in interfaceMessageProcessor
-
resumeRemotely
public void resumeRemotely()
Description copied from interface:MessageProcessor
Execute resume tasks of a message processor in cluster mode- Specified by:
resumeRemotely
in interfaceMessageProcessor
-
-