Custom tasks
We can also create and schedule our custom task implementations. In this section, we will explain the process of scheduling our custom task implementations.
The first step for creating a custom task is to make a Java program that will handle the logic of the task. The Java class should implement the org.apache.synapse.task.Task
interface that has a single method called execute()
with the logic of the procedure that will be to shoot every interval or cron
expression matches.
Also, our task should implement the ManagedLifecycle
interface that will be used by the creation and deletion workflow. This interface has two methods:
init(SynapseEnvironment)
: This will be executed in the creation of the taskdestroy()
: This will be executed before deleting it
Our custom task implementation will have the following structure:
public class CustomTask implements Task, ManagedLifecycle { private Log log = LogFactory.getLog(CustomTask.class); private SynapseEnvironment synapseEnvironment...