Automate Your Application Endpoints with SAP Job Scheduling Service

Objectives

After completing this lesson, you will be able to:
  • Create jobs and schedules to automate the execution of REST APIs for your cloud applications in the Cloud Foundry environment.
  • Integrate the SAP Job Scheduling service with the SAP Alert Notification service for SAP BTP.

SAP Job Scheduling Service

What Is SAP Job Scheduling Service?

SAP Job Scheduling service lets you define and manage jobs that run once or on a recurring schedule. You can also:

  • Use this runtime-agnostic service to schedule action endpoints in your application or long-running processes using Cloud Foundry tasks
  • Use REST APIs to schedule jobs, including long-running jobs asynchronously, and create multiple schedule formats for complex and straightforward recurring schedules
  • Manage jobs and tasks, and manage schedules with a web-based user interface

For more information, see What Is SAP Job Scheduling Service?.

Business Scenario

The Rotating Banana team has developed a cloud application that is deployed to the SAP BTP, Cloud Foundry environment. This cloud application can have multiple operation-related activities that need to be run on a specific schedule. For example, your application can have an endpoint /backup that needs to be executed every day, or /syncdata that fetches and updates data from a remote server that needs to be executed every 5 minutes.

How to Automate the Execution of an Application Endpoint

  1. Create a Service Instance and Establish Trust
    1. Create a service instance of the SAP Job Scheduling service.

      You can do it in the SAP BTP cockpit or the CF CLI.

      Don’t provide additional JSON parameters when asked to.

    2. Modify the xs-security.json for the SAP Authorization and Trust Management (XSUAA) service binding to the cloud application to include grant-authorities-to-apps and reference the name of the Job Scheduling service instance you’ve created. See more details in Secure Access.
    3. Update the XSUAA service instance.
    4. Bind the Job Scheduling service instance to the cloud application.Graphic showing the relation between the Job Scheduling service, the cloud application, and xsuaa
    5. Access the Job Scheduling service dashboard.
  2. Create a Job and a Schedule
    1. In the dashboard, choose Jobs.
    2. To create a job using the application endpoint, choose Create Job.
      • Give the job a name in the Name field.
      • In the Action field, provide an HTTP endpoint of the cloud application that the service will call.
      • Select an HTTP Method from the drop-down.
    3. Choose the name of the job you’ve just created. You’re now on the Overview page of the job.
    4. Choose Schedules in the left-side navigation menu.
    5. Choose Create Schedule.
    6. Select Recurring – Repeat Interval from the Pattern drop-down menu.
    7. In the Value field, enter 1 day.

    The goal is to set up the job to run every day.

    For more information about other types of schedules, see Schedule Types.

    For more information about the synchronous and asynchronous modes, see Asynchronous Mode.

  3. Monitor the Execution
    1. Choose the name of the job you’ve just created. Then, choose Schedules in the left-side navigation menu.
    2. Choose Recurring Schedule (Repeat Interval) - 1 day. You’re now at the Schedule Overview page.
    3. Choose Run Logs in the left-side navigation menu. You’re now at the Schedule Run Logs page, where all schedule executions are listed.
    4. The SAP Job Scheduling service automatically removes run logs 15 days after they're generated. You can archive run logs before the clean-up starts by downloading them to your local system using any of the following options:
      • On the Run Logs page, choose Download Run Logs.
      • Use the Retrieve Job Run Logs API. See Retrieve Job Run Logs.

Enable Integration with SAP Alert Notification Service for SAP BTP

Business Scenario

The Rotating Banana application can have many endpoints executed by the SAP Job Scheduling service. However, constant monitoring isn't necessary. As an administrator, you can use the SAP Alert Notification service for SAP BTP to receive events for successful or failed executions of these endpoints. This way, you'll only receive notifications for important executions or failures.

How to Enable Integration with SAP Alert Notification Service

  1. Ensure you have a running instance of the SAP Alert Notification service in your space.
  2. Edit your job to enable the SAP Job Scheduling service to send events to the SAP Alert Notification service in case of successful or failed executions. To do that, switch on the respective toggles in the Edit Job dialog.
  3. Configure a simple e-mail notification in the SAP Alert Notification service's UI to test if it's working. See Managing Actions > Email Action Type.

Summary

After this lesson, you can create jobs and schedules to automate the execution of REST APIs for your cloud applications in the Cloud Foundry environment. Also, you can integrate the SAP Job Scheduling service with the SAP Alert Notification service for SAP BTP.