Step 13 of 21 · 3 minutes

The Hung Job

The Scenario

A job has been "processing" for 2 hours. The external fraud detection API is unresponsive, and the job is stuck waiting for a response that may never come.

The worker thread is blocked and can't process other jobs.

The Challenge

How do we prevent jobs from running forever when external dependencies hang?

The Solution

Use Job Timeouts to automatically fail jobs that take too long:


@Job(processTimeOut = "PT5M")  // Fail after 5 minutes
public void callExternalAPI() {
    externalService.callSlowAPI();
}

If the job exceeds the timeout, JobRunr marks it as FAILED and frees the worker. The job can then retry with exponential backoff (when the API might be responsive again).

Read the documentation →

Try It Yourself

The export job has a timeout configured. If the government API is slow, watch the job fail after the timeout and retry automatically.
You need to log in to perform write operations. You can still view the code solution and dashboard.
Loading code...