36.2.1Batch Job Endpoint

 

The Batch Job Endpoint can be used to view the status of running background jobs.

36.2.2Fetch All Batch Jobs

 
This method requires the VIEW_BATCH_JOBS permission.

This method will return all batch jobs on the server for a given module.


To invoke:

GET http://localhost:9000/batch2-jobs/modules/{module_id}

Note the following path elements:

  • module_id – The FHIR Storage module ID that the batch job is running on.

You may also add the following URL parameters:

  • start=[int] – The index of the first result to return
  • count=[int] – The number of results to return
  • ended=[boolean] – Only show jobs that have ended

The server will produce a response resembling the following:

{
   "jobs": {
      "DELETE_EXPUNGE": [
         {
            "name": "DELETE_EXPUNGE",
            "id": "6670eb0a-bb66-4c59-ac5e-ca57a09ce839",
            "version": 1,
            "status": "IN_PROGRESS",
            "createTime": "2023-04-25T12:40:50.353-04:00",
            "startTime": "2023-04-25T12:40:50.353-04:00",
            "errorCount": 0
         }
      ],
      "REINDEX": [
         {
            "name": "REINDEX",
            "id": "fe7e00b8-bfbc-4545-91fe-85b9a1b96296",
            "version": 1,
            "status": "COMPLETED",
            "createTime": "2023-04-25T12:00:29.106-04:00",
            "startTime": "2023-04-25T12:00:29.217-04:00",
            "endTime": "2023-04-25T12:01:06.382-04:00",
            "combinedRecordsProcessed": 0,
            "errorCount": 0,
            "estimatedTimeRemaining": "0ms"
         }
      ]
   }
}

36.2.3Fetch Batch Job Names

 
This method requires the VIEW_BATCH_JOBS permission.

This method will return the names of all batch jobs on the server for a given module.


To invoke:

GET http://localhost:9000/batch2-jobs/modules/{module_id}/names

Note the following path elements:

  • module_id – The FHIR Storage module ID that the batch job is running on.

The server will produce a response resembling the following:

{
   "jobTypes": [
      {
         "name": "BULK_EXPORT"
      },
      {
         "name": "BULK_IMPORT_PULL"
      },
      {
         "name": "DELETE_EXPUNGE"
      },
      {
         "name": "REINDEX"
      },
      {
         "name": "bulkImportJob"
      },
      {
         "name": "termCodeSystemDeleteJob"
      },
      {
         "name": "termCodeSystemVersionDeleteJob"
      }
   ]
}

36.2.4Fetch All Job Instances

 
This method requires the VIEW_BATCH_JOBS permission.

This method will return all instances (including running, complete, and failed) of a given batch job.


To invoke:

GET http://localhost:9000/batch2-jobs/modules/{module_id}/names/{job_name}/jobs

Note the following path elements:

  • module_id – The FHIR Storage module ID that the batch job is running on.
  • job_name – The name of the running job.

You may also add the following URL parameters:

  • start=[int] – The index of the first result to return
  • count=[int] – The number of results to return
  • ended=[boolean] – Only show jobs that have ended

http://localhost:9000/batch2-jobs/modules/persistence/names/REINDEX/jobs?start=0&count=20&ended=false

The server will produce a response resembling the following. Note that for each job instance, you will have at least one job execution.

{
   "name": "REINDEX",
   "jobs": [
      {
         "name": "REINDEX",
         "id": "c0111ac7-c9fb-4034-8b91-ef382ae4547f",
         "version": 1,
         "status": "IN_PROGRESS",
         "createTime": "2023-04-25T12:52:32.417-04:00",
         "startTime": "2023-04-25T12:52:32.417-04:00",
         "errorCount": 0
      }
   ]
}

36.2.5Cancel Job Execution

 
This method requires the MANAGE_BATCH_JOBS permission.

This method cancels a given job.


To invoke:

GET http://localhost:9000/batch2-jobs/modules/{module_id}/jobs/{job_id}/cancel

Note the following path elements:

  • module_id – The FHIR Storage module ID that the batch job is running on.
  • job_id – The numeric ID of the job execution. Note that this is not the execution UUID, it is a numeric value.

The server will produce a response resembling the following. Note that for each job instance, you will have at least one job execution.

{
   "operation": "Cancel job instance 5cd41393-ba25-4c93-b7c1-f2dc478075b3",
   "success": true,
   "message": "Job instance <5cd41393-ba25-4c93-b7c1-f2dc478075b3> successfully cancelled."
}