Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Configuring server for task handling

The task scheduling configuration is a generic configuration, which is used by any component that requires the task scheduling functionality. Scheduled tasks support many modes of operations, where it fully supports load balancing and fail-over of tasks. The task configuration file can be found in the tasks-config.xml file stored in the <DSS_HOME>/repository/conf/etc/ directory. The default configuration is as follows: 

Code Block
<tasks-configuration xmlns:svns="http://org.wso2.securevault/configuration">
    <taskServerMode>AUTO</taskServerMode>
    <taskServerCount>2</taskServerCount>
 
	<!-- The default location resolver configuration -->
    <defaultLocationResolver>
        <locationResolverClass>org.wso2.carbon.ntask.core.impl.RoundRobinTaskLocationResolver</locationResolverClass>
    </defaultLocationResolver>
    <taskClientDispatchAddress>https://localhost:9448</taskClientDispatchAddress>
    <remoteServerAddress>https://localhost:9443</remoteServerAddress>
    <remoteServerUsername>admin</remoteServerUsername>
    <remoteServerPassword>admin</remoteServerPassword>
    <!--remoteServerPassword svns:secretAlias="remote.task.server.password"></remoteServerPassword-->
</tasks-configuration>

Given below are the task handling settings that you can configure for your server using the tasks-config.xml file.

...

  • AUTO is the default task handling mode. This setting detects if clustering is enabled in the server and automatically switches to CLUSTERED task handling mode.
  • STANDALONE mode is used when the Carbon server is used as a single installation. That is, tasks will be managed locally within the server.
  • CLUSTERED mode is used when a cluster of Carbon servers are put together. With this setting, if one of the servers in the cluster fail, the tasks will be rescheduled in one of the remaining server nodes. This requires Axis2 clustering to work.
  • REMOTE mode is used when all tasks should be triggered using an independent task handling server such of WSO2 Task Server. That is, all carbon servers using such an external task handling server should be running on REMOTE mode, while the task handling server can be running on AUTO, STANDALONE or CLUSTERED mode. See how WSO2 Task Server can be used to interface tasks from other servers.

...

Code Block
<defaultLocationResolver>
        <locationResolverClass>org.wso2.carbon.ntask.core.impl.RuleBasedLocationResolver</locationResolverClass>
        <properties>
            <property name="rule-1">HIVE_TASK,HTTP_SCRIPT*,192.168.1.*</property>
            <property name="rule-2">HIVE_TASK,.*,192.168.2.*</property>
            <property name="rule-5">.*,.*,.*</property>
        </properties>
</defaultLocationResolver>

As shown in this example, the property names (rule-1, rule-2 and rule-5) define a sequence for the list of properties in the configuration. Therefore, scheduled tasks will evaluate the criteria specified in each property according to the sequence order; i.e., rule-1 is checked before rule-2. In other words, the scheduled task will first check if it matches the criteria in rule-1, and if it does not, it will check rule-2.

Note

The RuleBasedLocationResolver allows you to address scenarios where tasks are required to be executed in specific server nodes first. Then, it can fail-over to another set of server nodes if the first (preferred) one is not available.

  • <taskClientDispatchAddress>: The address to which the remote task server should dispatch the trigger messages. Usually this would be an endpoint to a load balancer.
  • The <remoteServerAddress>, <remoteServerUsername> and <remoteServerPassword> is used to specify the sever address, user name and password of the remote task handling server. That is, these settings are only applicable when the <taskServerMode> is REMOTE. For example, see how you can use WSO2 Task Server as a remote task server.

The default values in the tasks-config.xml file ensures that minimal changes are required when running in both standalone and clustered modes. The task server mode is set to "AUTO" by default, which automatically detects if clustering is enabled in the server, and by default switches to clustered mode of scheduled tasks. The task server count is set to "2" by default, where in a clustered setup, at least two nodes will be there. This setting basically represents the number of servers that will be waiting for scheduled tasks to be shared between the given number of nodes at  startup. For example, if 10 tasks were saved and scheduled earlier, for some reason, later if the cluster is brought down, and then again, when individual servers are coming up, we do not want the first server up to schedule all the tasks. Instead, we will want several servers to come up and share the 10 tasks between them.

...

For instructions on how to configure the Task Scheduling component for you server, see the admin guide in the WSO2 Carbon documentation.

Adding Scheduled Tasks

Follow the steps given below to schedule a task.

...