Step 18 of 22
·
4 minutes
Work That Runs Elsewhere
The Scenario
Applications the cheap checks cannot decide go to the fraud model, which runs on a GPU cluster
next to the bank rather than inside this JVM. A run takes minutes. Borderline cases go further still,
to a compliance officer who answers when they answer.
Blocking a worker thread on either of those burns a worker for nothing, and a restart loses the fact
that the work was ever started.
The Challenge
How do we keep work that runs somewhere else on the dashboard, with the same retries, timeouts and results?
The Solution
Create an
external job. JobRunr runs your method, which hands the case to the other
system, and then parks the job in
PROCESSED instead of finishing it:
UUID jobId = jobScheduler.create(anExternalJob()
.withName("Fraud review of " + card.getEmail())
.withProcessTimeOut(Duration.ofMinutes(30))
.withDetails(() -> handOverToRiskCluster(card))).asUUID();
// ... minutes later, the cluster calls back
jobScheduler.signalExternalJobSucceeded(jobId, verdict);
jobScheduler.signalExternalJobFailed(jobId, "model flagged this application");
jobScheduler.signalExternalJobProgress(jobId, progress);
No worker thread is held while the model runs, but the job is still yours: it keeps its labels, its
result and its place in the dashboard. And because it carries a process timeout, a cluster that never
reports back fails the job instead of leaving it waiting forever.
Read the documentation →
Try It Yourself
- Send an application to the risk cluster and find it under Processing, waiting in
PROCESSED
- Report the verdict, the way the cluster's webhook would
- Open the job and read the answer the external system left behind
You need to log in to perform write operations. You can still view the code solution and dashboard.