Scheduling mediations using WSO2 Enterprise Integrator

Krishni Andradi
WSO2 Solution Architecture Team Blog
3 min readNov 8, 2019

Scheduling mediations

WSO2 Enterprise Integrator is a fully open-source product that helps to integrate and connecting different heterogeneous applications systems. It has the capabilities of Business Process Management, Enterprise Service Bus, Messaging queues, Analytics and Tooling.

Other than that we can use WSO2 Enterprise integrator to schedule tasks, schedule meditation sequences.

For example, I want to poll a folder every 10 seconds to search for files and process them.

Here the first thing we need to do is creating mediation sequences as per our need. First, create an ESB solution project and add a mediation sequence to it and develop your logic.

Copy and paste the content in the following gist to your sequence.

fileProcessingSequence.xml

For more clarifications on the above sequence refer following articles.

Here this sequence will read all the file locations in a specific root directory and move each of those files to separate locations after processing those files.

Next add a scheduled task to the ESB solution project by, right-click on the project, New>Scheduled task>Next>Create a new scheduled task artifact.

Schedule task in form view

Now you can start specifying details.

Under trigger information, you can specify a simple trigger or a CRON expression.

Under simple trigger type, specify interval as 10, as we want our task to run by every 10 seconds.

And specify count as -1, to indicate unlimited, as we want this to happen without a stop.

Keep other values to the default, and add the following two properties to the task in the source view

Here sequence name property has to point to the previous file processing sequence we created. So that sequence file name should be given to the sequence name properties value.

As we kept the task implementation value to org.apache.synapse.startup.tasks.MessageInjector which is the default value, Now our scheduled task is trying to inject some value to the sequence which we specified in the previous step.

If we are not specifying any value to inject it will give an error. Even though we dont need to inject any message we have to give a simple message input due to that.

So I have added a another property with a simple XML message.

Now build this artifact and deploy it to the WSO2 Enterprise Integrator.

At the server startup, it will execute the scheduled task once and then it will keep on executing according to the trigger we specified.

This is a very good feature that WSO2 Enterprise Integrator comes with, and you can extend this feature as per your need. By giving a complex trigger type, by injecting a message which will be useful to the sequence, by giving a different task implementation and so on.

Thank You

--

--