Configuring JEUS Scheduler
This chapter describes how to configure JEUS Scheduler in a JEUS configuration file or deployment descriptor (DD).
1. Overview
The following configuration is required to use JEUS Scheduler Service.
-
Configuring Scheduler Service on JEUS server
To access the JEUS server Scheduler Service or to execute a recurring task on the JEUS server using the Job-list, Scheduler Service must be activated by manually editing the configuration file domain.xml. Then, the server starts Scheduler Service at startup.
The following is an outline of the configuration required.
-
Enable Scheduler Service.
-
Configure the thread pool for Scheduler Service.
-
Set the Job-list scheduled to execute on the server.
-
-
Configuring Scheduler Service on the client container
-
Repeat the above settings in the deployment descriptor (DD) file.
-
Simply put, in order to use the scheduler, you need to activate the Scheduler Service, configure the thread pool, and finally, set the Job-list to execute the actual tasks.
2. Configuring JEUS Scheduler on the Server
This section describes how to configure the scheduler on the server by manually editing the domain.xml file.
To remotely access the JEUS server Scheduler Service or execute a recurring task on JEUS server using the Job-list, the Scheduler Service must be activated on the server. To activate the service, you need to add the setting in the domain.xml file. Then, the server starts Scheduler Service at startup.
The following are the steps for adding the job from Schedule Class Inheritance to the server.
...
<server>
...
<scheduler>
<enabled>true</enabled>
<pooling>
<dedicated>
<min>0</min>
<max>10</max>
<keep-alive-time>60000</keep-alive-time>
<queue-size>4096</queue-size>
<stuck-thread-handling>
<max-stuck-thread-time>3600000</max-stuck-thread-time>
<action-on-stuck-thread>None</action-on-stuck-thread>
<stuck-thread-check-period>300000</stuck-thread-check-period>
</stuck-thread-handling>
</dedicated>
</pooling>
<job-list>
<job>
<name>SimpleTask</name>
<class-name>java.sample.scheduler.SimpleTask</class-name>
<begin-time>2024-08-26T10:30:00</begin-time>
<end-time>2024-08-27T10:30:00</end-time>
<interval>
<hourly>1</hourly>
</interval>
<count>10</count>
</job>
</job-list>
</scheduler>
...
</server>
...
For more information about the <pooling> tag in the domain.xml file above, refer to Thread Pool Configuration in JEUS Server Guide.
Also, for a description of the <job-list> entry, see Configuring Job-list below.
Scheduler configuration changes are not applied dynamically. The changes take effect after the server restarts. |
When the server restarts, the new job executes and the result can be checked in the server logs.
##### waked on Mon Aug 26 10:30:00 KST 2024 ##### waked on Mon Aug 26 11:30:00 KST 2024
3. Configuring Job-list
This section describes how to register a job.
You can register a job or schedule it at JEUS server startup in the JEUS configuration file. A job is a single task unit that is scheduled. A job class must implement the jeus.schedule.ScheduleListener interface, and the class and its related classes must be compressed into a JAR file and saved in the following location.
-
Since the following directory is not synchronized between the Master Server and a Managed Server (hereafter MS), you must synchronize them manually for every machine to run the scheduler service.
DOMAIN_HOME/lib/application
-
You must create the following directory.
SERVER_HOME/lib/application
JEUS Scheduler Service executes jobs that are configured on the server.
The following items must be configured.
Item | Description |
---|---|
Name |
Specifies the name of a Job. |
Class Name |
Specifies the fully qualified name of the class that performs the job. |
Description |
Specifies the job description. |
Begin Time |
Initial time to execute the task. If the time is not set, the task executes when the JEUS server starts.
If the Begin Time of a registered job has already passed, the initial execution time is adjusted to a time after the current time. |
End Time |
Time when the task terminates. If the time is not set, the task does not terminate.
If End Time has already passed, the task does not execute at all. |
Interval |
Specifies the period at which the Job is performed. You can select from the options below.
|
Count |
Maximum number of executions. If Count is not set or set to -1, there is no limit for the number of executions. |
If a task is registered in the Job-list, the task executes at a fixed rate and therefore maintains a stable execution cycle. But if executing a task is delayed, the task may be executed concurrently by another thread. To ensure this process, you must check if the task object is thread safe. |
4. Configuring a Thread Pool
Scheduler Service controls a thread pool by adjusting the number of threads required for service execution. A thread pool can be either a shared thread pool that uses the system thread pool or a dedicated thread pool that needs to be created individually.
This section describes how to set up a thread pool using the console tool. For more information about each element, refer to Thread Pool Configuration in JEUS Server Guide.
4.1. Shared Thread Pool
If Scheduler Service uses a shared thread pool, you need to configure the number of threads only.
Using the console tool
The following shows how to set the thread pool of the scheduler using the console tool (jeusadmin).
[MASTER]domain1.adminServer>modify-system-thread-pool server1 -service scheduler -r 10 Successfully performed the MODIFY operation for The scheduler thread pool of the server (server1)., but all changes were non-dynamic. They will be applied after restarting. Check the results using "show-system-thread-pool server1 -service scheduler or modify-system-thread-pool server1 -service scheduler". [MASTER]domain1.adminServer>show-system-thread-pool server1 -service scheduler Shows the current configuration. the system thread pool of the server (server1) ================================================================================ +---------------------------------------------------------+--------------------+ | Min | 0 | | Max | 100 | | Keep-Alive Time | 300000 | | Queue Size | 4096 | | Max Stuck Thread Time | 3600000 | | Action On Stuck Thread | IGNORE_AND_REPLACE | | Stuck Thread Check Period | 300000 | | Reserved Threads for the Service transaction | 0 | | Reserved Threads for the Service scheduler | 10 | | Reserved Threads for the Service namingserver | 0 | +---------------------------------------------------------+--------------------+ ================================================================================
4.2. Dedicated Thread Pool
If Scheduler Service uses a dedicated thread pool, the thread pool can be configured using the console tool (jeusadmin).
The thread pool configuration of the Scheduler Service is dynamic and therefore the server does not need to be restarted. However, the server must be restarted when changing from using the shared thread pool to the dedicated thread pool for changes to take effect. |
Using the console tool
The following shows how to configure the scheduler’s thread pool using the console tool (jeusadmin).
[MASTER]domain1.adminServer>show-service-thread-pool server1 -service scheduler Shows the current configuration. ================================================== +------+-----------------------------------------+ (No data available) ================================================== [MASTER]domain1.adminServer>modify-service-thread-pool server1 -service scheduler -min 0 -max 20 Successfully performed the MODIFY operation for The scheduler thread pool of the server (server1)., but all changes were non-dynamic. They will be applied after restarting. Check the results using "show-service-thread-pool server1 -service scheduler or modify-service-thread-pool server1 -service scheduler". [MASTER]domain1.adminServer>show-service-thread-pool server1 -service scheduler Shows the current configuration. ===================================================================== +---------------------------------------------------------+---------+ | Min | 0 | | Max | 20 | | Keep-Alive Time | 60000 | | Queue Size | 4096 | | Max Stuck Thread Time | 3600000 | | Action On Stuck Thread | NONE | | Stuck Thread Check Period | 300000 | +---------------------------------------------------------+---------+ =====================================================================
5. Configuring a Client Container
This section describes how to configure JEUS Scheduler that is running on a client container when using a Jakarta EE application. Add the following <scheduler> element to the JEUS DD file, jeus-client-dd.xml.
<?xml version="1.0"?>
<jeus-client-dd>
<module-info>
...
</module-info>
...
<scheduler>
<enabled>true</enabled>
<!-- Scheduler Thread-pool settings -->
<pooling>
<dedicated>
<min>2</max>
<max>10</max>
<keep-alive-time>60000</keep-alive-time>
<queue-size>4096</queue-size>
<stuck-thread-handler>
<max-stuck-thread-time>3600000</max-stuck-thread-time>
<action-on-stuck-thread>None</action-on-stuck-thread>
</stuck-thread-handler>
</dedicated>
</pooling>
</scheduler>
...
</jeus-client-dd>
To apply the changes after modifying the previous configuration file, the JEUS server does not need to be restarted, but client modules and client containers must be restarted.
|
The following shows how to set jobs that run on client containers.
<scheduler>
...
<job-list>
<job>
<class-name>samples.ScheduleJob</class-name>
<name>ScheduleJob</name>
<description>This is a sample for scheduler service</description>
<begin-time>2024-08-26T00:00:00</begin-time>
<end-time>2024-08-27T00:00:00</end-time>
<interval>
<minutely>30</minutely>
</interval>
<count>-1</count>
</job>
</job-list>
</scheduler>