This topic describes how to use Scheduler, including configuring Scheduler and SOFAMQ. The content described in this topic includes:
- Coding: Integrate Scheduler. To download the sample code, see Download code.
- Operations on the console: After completing local coding, you must submit related configurations on the console of the server, including the configurations of the scheduled task, message type, and subscription relationship.
- Verification based on logs: After deploying a sample app on the SOFAStack platform, you need to view logs to check whether the app starts running properly.
The sample code in this course is developed based on SOFABoot. Before starting this course, ensure that you are familiar with SOFABoot and the relationship between Scheduler and SOFAMQ.
- For basic knowledge of SOFABoot, see SOFABoot > Quick start.
- For the running mechanism of Scheduler, see Scheduler (only for the private cloud) > Overview.
- For the running mechanism of SOFAMQ, see SOFAStack MQ > Overview.
Click here to download the sample project.
The scheduled tasks are managed and controlled on the cloud. Therefore, you must deploy the app on the cloud.
application.properties file of SOFABoot contains three parameters related to the workspace. Before deploying the app on the cloud, determine the target workspace, check the workspace parameters, and modify them as needed. For more information, see SOFARPC > Service publication and reference > Reference the SOFARPC service. Related parameters include:
The sample app is a common SOFABoot Core project. Pack it and deploy it on the cloud by referring to SOFABoot > Compilation and Deployment > Cloud Deployment.
Configure a scheduled task by referring to Add and manage message-based scheduled tasks. Ensure that the task name is the same as that specified with
eventCode in the code. For more information, see
Add the message topic, consumption group, and subscription relationship in the SOFAMQ console. For more information, see topics related to the message type and subscription relationship in SOFAMQ.
- Ensure that the message topic, event code, and subscription group are the same as those in the code. For more information, see
- After configuring the message topic and subscription relationship, validate them.
Log on to the schedulertutorial ECS on the SOFAStack platform over SSH on the website and view logs in
/home/admin/logs/tracelog/msg-sub-digest.log. The log file is sent from SOFAMQ and records logs in the following format. Check the logs to determine whether the sample app starts running properly.