Scheduling a Task Using the Default Implementation
According to the default task implementation in the ESB profile, a task can be configured to inject messages, either to a defined endpoint, to a proxy service or a specific sequence defined in the ESB. The sections below demonstrate an example of scheduling a task using the default implementation, to inject an XML message and to print it in the logs of the server.
Creating the Task
Follow the steps below to create the task, which you want to schedule.
Creating the ESB Project
Open WSO2 EI Tooling and click File → New → ESB Solution Project.
Enter ScheduleDefaultTask as the ESB Project Name and click Finish.
Creating the Sequence
In the Project Explorer, right click on the ScheduleDefaultTask Project and click New → Sequence.
Click Create New Sequence and click Next.
Enter the Sequence Name as InjectXMLSequence and click Finish.
Drag and drop a Log mediator and a Drop mediator from the Mediators Palette.
Click on the Log mediator, and in the Properties section enter the following details.
Log Category:
INFOLog Level:
CUSTOM
Creating the Scheduled Task
In the Package Explorer, right click on the ScheduleDefaultTask Project and click New → Other.
Type Scheduled Task in the search, select it and click Next.
Click Create a New Scheduled Task Artifact and click Next.
Enter the below details and click Finish.
Task Name:
InjectXMLTaskCount:
-1Interval (in seconds): 5
In the Package Explorer, you view the
InjectXMLTaskcreated task created in thesrc/main/synapse-config/tasksdirectory under the ScheduleDefaultTask project.
Defining the properties of the Task
In the Form View of the
InjectXMLTask.xmlfile, click the Task Implementation Properties button.Select XML as the Parameter Type of the message parameter, enter
<abc>This is a scheduled task of the default implementation.</abc>as the XML message in the Value/Expression field and click OK.
Deploying the Task
Open the
pom.xmlfile of the Composite Application Project and select the artifacts that need to be deployed.Start the ESB profile by adding the ScheduleDefaultTaskCompositeApplication. For instructions, see Running the ESB profile via Tooling.
Viewing the output
You view the XML message you injected (i.e.,<abc>This is a scheduled task of the default implementation.</abc>) getting printed in the logs of the ESB Profile every 5 seconds.