spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.31k stars 40.71k forks source link

Add execution information in Quartz job detail #43226

Open snicoll opened 1 day ago

snicoll commented 1 day ago

Reviewing #43086 and brainstorming with @wilkinsona we believe that the detail of a job should specify whether it's running or not and additional information if it is.

Doing so will help with triggering a new execution on demand.

The detail of a test job is currently as follows:

{
    "className": "com.example.demoquartz.DemoQuartzApplication$TestJob",
    "data": {},
    "durable": true,
    "group": "DEFAULT",
    "name": "testJob",
    "requestRecovery": false,
    "triggers": [
            "group": "DEFAULT",
            "name": "testJobTrigger",
            "nextFireTime": "2024-11-20T10:26:43.791+00:00",
            "previousFireTime": "2024-11-20T10:25:43.791+00:00",
            "priority": 5
    ]
}

For a Job who's currently running, we'd like the description to improve as follows:

{
  "className": "com.example.demoquartz.DemoQuartzApplication$TestJob",
  "data": {},
  "durable": true,
  "group": "DEFAULT",
  "name": "testJob",
  "requestRecovery": false,
  "running": true,
  "triggers": [
    {
      "executions": {
        "previous": "2024-11-20T10:25:43.791+00:00",
        "next": "2024-11-20T10:26:43.791+00:00",
        "current": {
          "fireTime": "2024-11-20T10:25:43.794+00:00",
          "recovering": false,
          "refireCount": 0
        }
      },
      "group": "DEFAULT",
      "name": "testJobTrigger",
      "priority": 5
    }
  ]
}

If the job is not running, it would be:

{
  "className": "com.example.demoquartz.DemoQuartzApplication$TestJob",
  "data": {},
  "durable": true,
  "group": "DEFAULT",
  "name": "testJob",
  "requestRecovery": false,
  "running": false,
  "triggers": [
    {
      "executions": {
        "previous": "2024-11-20T10:25:43.791+00:00",
        "next": "2024-11-20T10:26:43.791+00:00",
      },
      "group": "DEFAULT",
      "name": "testJobTrigger",
      "priority": 5
    }
  ]
}

For backward compatible reason, the nextFireTime and previousFireTime should still be present but we'll stop documenting them.

wilkinsona commented 1 day ago

For consistency, I wonder if we should have some common structure for the executions:

"executions": {
  "previous": {
    "fireTime": "2024-11-20T10:25:43.791+00:00"
  },
  "next": {
    "fireTime": "2024-11-20T10:26:43.791+00:00"
  },
  "current": {
    "fireTime": "2024-11-20T10:25:43.794+00:00",
    "recovering": false,
    "refireCount": 0
  }
},
snicoll commented 1 day ago

Current proposal is as follows for http :8080/actuator/quartz/jobs/DEFAULT/testJob:

HTTP/1.1 200
Connection: keep-alive
Content-Type: application/vnd.spring-boot.actuator.v3+json
Date: Wed, 20 Nov 2024 15:13:17 GMT
Keep-Alive: timeout=60
Transfer-Encoding: chunked

{
    "className": "com.example.demoquartz.DemoQuartzApplication$TestJob",
    "data": {},
    "durable": true,
    "group": "DEFAULT",
    "name": "testJob",
    "requestRecovery": false,
    "running": true,
    "triggers": [
        {
            "executions": {
                "current": {
                    "fireTime": "2024-11-20T15:13:11.459+00:00",
                    "recovering": false,
                    "refireCount": 0
                },
                "next": {
                    "fireTime": "2024-11-20T15:14:11.225+00:00"
                },
                "previous": {
                    "fireTime": "2024-11-20T15:13:11.225+00:00"
                }
            },
            "group": "DEFAULT",
            "name": "testJobTrigger",
            "nextFireTime": "2024-11-20T15:14:11.225+00:00",
            "previousFireTime": "2024-11-20T15:13:11.225+00:00",
            "priority": 5
        }
    ]
}