In a clustered environment, tasks are distributed among server nodes according to the round-robin method , by default. If required, you can change this default task handling behavior so that tasks are distributed randomly, or according to a specific rule. This is a server-level setting that is configured in the
Also, note that a scheduled task will only run on one of the nodes (at a given time) in a clustered environment. The task will failover to another node, only if the first node fails.
Follow the instructions below to add and schedule a task in ESB Management Console.
- Sign in. Enter youruser nameand your user name and password to log in to the ESB Management Console.
- Click Main in the left menu to access the Manage menu.
- In the Manage menu, click Scheduled Tasks under Service Bus.
- The Scheduled Tasks page appears, where you can add, edit, and delete tasks.
- Click Add Task.
- The New Scheduled Task page appears. Enter the required details into the fields.
- Task Name - Name of a scheduled task.
- Task Group - The group name to grouping tasks. The group name
synapse.simple.quartzbelongs to ESB - Synapse. All available groups are displayed as a drop-down menu. If there are tasks belong belonging to some other domains, for example WSO2 Mashups tasks, then those will be shown here as a as separate group names.
- Task Implementation - The implementation class of the task. To use the default task implementation that is available with the ESB (and therefore can be used without downloading any third-party libraries or custom JARs), specify
org.apache.synapse.startup.tasks.MessageInjector. This class simply injects a specified message into the Synapse environment at ESB startup. For more information on writing custom task implementations, see Writing Tasks.
- Trigger Type- Trigger type for the task. This can be selected as either "Simple" or "Cron."
- Simple Trigger - Defined by specifying a
interval, implying that the task will run a
countnumber of times at specified intervals.
- Count - The number of times the task will be executed.
- Interval - The interval between consecutive executions of a task.
- Cron Trigger - Defined using a cron expression.
- Simple Trigger - Defined by specifying a
Pinned Servers - The list of ESB server nodes that will run the task. You can specify the IP addresses of the required nodes.
Anchor pinned_servers pinned_servers Info
This setting can be used if you want the task to run on a selected set of nodes in an ESB cluster. Note that the task will only run on one of the nodes at a time. It will failover to another node, only if the first node fails.
As explained above, pinned servers will override the default task handling behavior defined at server-level (for this particular task). However, if rule-based task handling is specified at server-level, you need to ensure that the same server nodes you specify as pinned servers for the task are also specified for the task handling rule at server-level.
- Click Load Task Properties to see the instance properties of the task implementation.
- Use the instance properties fields as follows:
- Property Name - The unique name of the task property.
- Property Type- The type of property, either Literal or XML.
- Property Value - The value of the property.
- Action - Allows you to delete a property.
For more information on setting the properties for the default task implementation, see Examples and Injecting the message to a named sequence or proxy service below.
The org.apache.synapse.startup.tasks.MessageInjector implementation takes the following properties:
- format - defines the format of the message similar to Address Endpoint formats: soap11, soap12, pox, get
message - you can provide an XML or literal value depending on message format.
When you add a scheduled task, it is mandatory to provide a value for the message property. Therefore, even If you do not want to send a message body, you have to provide an empty payload as the value to avoid an exception being thrown.
- soapAction - specify the SOAP Action to use when sending the message to the endpoint.
- to - specify the endpoint address.
- injectTo - specify whether to inject a message to a proxy service or sequence. This field takes values 'sequence' or 'proxy' and 'main' to inject to main sequence.
- proxyName - if injectTo contains 'proxy' then the name of the proxy to inject the message to is specified here.
- sequenceName - if injectTo contains 'sequence' then the name of the sequence to inject the message to is specified here.
- Click Schedule to apply the settings.