Connect HTTP applications to XXL-JOB

Updated at:
Copy as MD

When your applications span multiple languages, frameworks, or deployment environments, installing a dedicated executor on each service adds operational overhead. XXL-JOB on Microservices Engine (MSE) solves this by triggering tasks through standard HTTP requests -- any service with an HTTP endpoint can participate in unified task scheduling without an executor or SDK.

Scenarios

ScenarioExample
External system integrationTrigger a third-party API on a schedule
Serverless function triggeringCall a Function Compute endpoint at fixed intervals
Traditional application schedulingSchedule tasks on Elastic Compute Service (ECS) instances or physical servers
Cross-VPC task triggeringReach services outside the XXL-JOB instance's Virtual Private Cloud (VPC) through a domain name
Multi-language environmentsSchedule tasks for services built with any language or framework

Benefits

  • Non-intrusive connection: Connect to task scheduling through the HTTP protocol without deploying an agent in your business system.

  • Cross-platform compatibility: Supports any service that provides an HTTP interface, regardless of the programming language or framework.

  • Flexible deployment: Supports Kubernetes and non-Kubernetes environments, including traditional ECS instances and physical servers.

  • Simple configuration: Connect the executor by entering the HTTP service endpoint.

How it works

Kubernetes environment

Bind a Kubernetes Service to an XXL-JOB application. All pods behind that Service become execution nodes. The scheduling center discovers each pod's availability and health through Kubernetes service discovery in real time.

Non-Kubernetes environment

Bind one or more domain names to an XXL-JOB application. All HTTP tasks under that application share these domain names. When a task triggers, the scheduling center selects a target domain name based on the application context and routing policy, then sends the HTTP request.

Prerequisites

Before you begin, make sure that you have:

Step 1: Create an HTTP application

  1. Log on to the XXL-JOB console and select a region in the top menu bar.

  2. Click the target instance to open its details page.

  3. In the left-side navigation pane, choose Application Management and click Create Application.

  4. In the Create Application dialog box, select HTTP Application and configure the following fields:

    FieldRequiredDescription
    AppNameYesUnique identifier for executor registration. 1--64 bytes. Supports letters, digits, underscores (_), and hyphens (-). Must start with a letter or digit.
    NameYesDescriptive name for the application. 1--64 characters.
    AccessTokenYesAuthentication token for executor registration. 6--32 characters. Supports letters and digits. The system auto-generates a value, which you can modify.
  5. Click OK.

The application appears in the application list with 0 executors. Proceed to Step 2 to connect an executor before running tasks.

Step 2: Connect an executor

Choose the connection method based on your deployment environment:

Connect to a Kubernetes Service

Before you begin

Make sure that:

  • The application runs in a Container Service for Kubernetes (ACK), Container Compute Service (ACS), or ACK Serverless cluster

  • The cluster and the XXL-JOB instance are in the same VPC

(Optional) Deploy a test HTTP application on ACK

If no HTTP application is available, deploy an NGINX service in ACK for testing.

Create the Deployment

  1. Log on to the ACK console and select a region in the top menu bar.

  2. Click the target cluster to open its details page.

  3. In the left-side navigation pane, choose Workloads > Deployments, and then click Create from Image.

  4. Configure the basic settings:

    FieldExample value
    Application Nametest-http-app
    Namespacedefault
    TypeStateless (Deployment)
    Number of Replicas2 (verifies load balancing)
  5. Configure the container:

    FieldValue
    Image Nameanolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
    Container Port80
    ProtocolTCP
  6. Click Create and wait for the Deployment to reach the Ready state.

Create the Service

  1. On the Deployment details page, click Configure Access Method.

  2. In the Create Service dialog box, configure the following settings:

    FieldExample value
    Service Nametest-http-app-service
    TypeClusterIP
    Associated WorkloadThe Deployment created in step 4
    Service Port80
    Container Port80
    ProtocolTCP
  3. Click Create and wait for the Service to be created.

Bind the Service to the application

  1. Return to the XXL-JOB console and go to the Application Management page.

  2. Find the HTTP application and click Connect to open the Connect Executor dialog box.

  3. Set Connection Type to Connect to K8s Service.

  4. Select the connection details:

    FieldDescription
    ClusterThe ACK cluster where the application is deployed.
    NamespaceThe namespace where the application runs, such as default.
    ServiceThe Service created earlier, such as test-http-app-service.
  5. Click OK.

After the connection succeeds, the application list displays the pods behind the Service, and the executor count updates from 0 to the actual number of pods.

Connect with a domain name

Important

Verify network connectivity between the XXL-JOB instance and the target domain name before proceeding. Tasks fail with a "no worker available" error if the domain is unreachable.

  1. On the Application Management page, find the HTTP application and click Connect to open the Connect Executor dialog box.

  2. Set Connection Type to Enter Domain Name.

  3. Configure the domain name settings:

    FieldRequiredDescription
    Executor AddressYesAn accessible HTTP service URL, such as https://httpbin.org.
    TagsNoLabels for routing policy, such as test-label.
  4. Click OK.

After the connection succeeds, the application list displays the connected domain name.

Step 3: Create an HTTP task

  1. In the left-side navigation pane, choose Task Management and click Create Task.

  2. Configure the basic task settings:

    FieldRequiredDescription
    Task NameYesA name for the task, such as test-http-task.
    Associated ApplicationYesThe HTTP application created in Step 1.
    Task TypeYesSelect HTTP.
  3. Configure the HTTP request:

    FieldRequiredDescription
    API PathYesThe request path. Must start with /, such as / or /v1/hello.
    Request MethodYesGET, POST, PUT, DELETE, or another HTTP method.
    TimeoutYesRequest timeout in seconds, such as 30.
  4. (Optional) Add request details:

    FieldDescription
    HeaderHTTP request headers, such as Content-Type: application/json.
    QueryURL query parameters, such as param1=value1&param2=value2.
    BodyRequest body for POST or PUT requests.
  5. Define success criteria: (Optional) Configure Success result parsing to extract values from the response using JSONPath or regular expressions.

    MethodDescriptionExample
    HTTP status codeMatch a specific status code.200
    Response body JSONEvaluate a JSONPath expression against the response body.$.code equals 200
    Response bodyCheck whether the response body contains a specific string."success"
  6. Configure failure retry:

    FieldDescriptionExample
    Task failure retriesNumber of retry attempts on failure.3
    Task failure retry intervalWait time between retries, in seconds.30
  7. Configure the schedule:

    FieldDescription
    Time Typecron or Fixed Frequency.
    Cron ExpressionA cron expression defining the schedule. See the reference table below.
    Time ZoneThe time zone for schedule evaluation.
    CalendarDaily scheduling or a specific calendar.
    Start TimeEffective immediately or at a specified time.

    Common cron expressions

    ExpressionSchedule
    0 0 12 * * ?Every day at 12:00 PM
    0 0/30 * * * ?Every 30 minutes
    0 0 9 * * ?Every day at 9:00 AM
    0 0 0 * * ?Every day at midnight
    0 0 9 ? * MON-FRIEvery weekday at 9:00 AM
  8. (Optional) Configure notifications:

    FieldDescription
    Success notificationNotification method for successful executions.
    Failure alarmAlarm configuration for failed executions.
    Notification MethodText message, webhook, email, phone call, or another method.
    Notification RecipientContacts to receive notifications.
  9. Click Finish.

The task appears in the task list with a status of Enabled.

Step 4: Test the task

  1. On the Task Management page, find the task and click Run Once.

  2. In the confirmation dialog box, click OK to trigger execution.

  3. In the left-side navigation pane, choose Task Instances to view execution records. Each record shows the execution ID, status, duration, and execution node. A status of Succeeded confirms the task completed correctly.

  4. Click an execution ID or click Log to inspect the full HTTP exchange: request method, URL, headers, body, response status code, response headers, and response body.

  5. (Optional) In the left-side navigation pane, choose Event Center to view the complete execution flow: Scheduled, Running, and Succeeded or Failed.

FAQ

"No worker available" error when running a task

The scheduling center cannot find an active executor for the application. The cause depends on your connection type:

  • Kubernetes connection: The ACK cluster has zero running nodes, or the pods behind the connected Service are not in the Running state. Verify that the Deployment has healthy pods and that the Service selector matches the Deployment labels.

  • Domain name connection: The configured domain name is unreachable from the XXL-JOB instance. Test connectivity from within the instance's VPC.

HTTP task type is missing from the task type list

The HTTP option appears only when the Associated Application is an HTTP application. Select the correct application and refresh the page.

Executor count stays at 0 after connecting to a Service

The Deployment behind the Service likely has no healthy pods.

  1. Confirm the Deployment replica count is greater than 0.

  2. Check that all pods are in the Running state and passing readiness probes.

The executor count updates automatically once pods become healthy.