Java
QuantumBPM/quantum-java-sdk - split into a plain Java client and a Spring Boot starter. Requires Java 21+ (the worker runtime uses virtual threads).
This tutorial evaluates a decision from Java, reads the result as a record, pins a model version and tests the rules with JUnit.
Installation
<!-- Plain Java client -->
<dependency>
<groupId>com.quantumbpm</groupId>
<artifactId>quantum-client</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Spring Boot starter - autoconfigured client + @JobWorker registration -->
<dependency>
<groupId>com.quantumbpm</groupId>
<artifactId>quantum-spring</artifactId>
<version>2.0.0</version>
</dependency>
Quick start (plain Java)
import com.quantumbpm.client.QuantumBPM;
import com.quantumbpm.client.auth.ClientCredentialsTokenProvider;
import com.quantumbpm.client.variables.Vars;
import java.util.UUID;
var provider = new ClientCredentialsTokenProvider(
"https://idp.example.com/realms/acme/protocol/openid-connect/token",
"billing-svc",
System.getenv("QUANTUMBPM_CLIENT_SECRET"));
QuantumBPM client = QuantumBPM.builder()
.baseUrl("https://quantumbpm.example.com")
.projectId(UUID.fromString("YOUR_PROJECT_ID"))
.tokenProvider(provider)
.build();
var result = client.dmn().evaluate(
"loan-eligibility",
new Vars().set("requestedAmt", 1000).set("creditScore", 720));
Quick start (Spring Boot)
application.yml:
quantumbpm:
base-url: https://quantumbpm.example.com
project-id: YOUR_PROJECT_ID
auth:
client-credentials:
token-url: https://idp.example.com/realms/acme/protocol/openid-connect/token
client-id: billing-svc
client-secret: ${QUANTUMBPM_CLIENT_SECRET}
worker:
enabled: true # default; scans @JobWorker beans
client-id: billing-svc
deployment:
enabled: true # default, deploys the files named by @Deployment
Then inject QuantumBPM anywhere and annotate handler methods with @JobWorker:
import com.quantumbpm.client.variables.Vars;
import com.quantumbpm.client.workers.Job;
import com.quantumbpm.spring.JobWorker;
import org.springframework.stereotype.Component;
@Component
public class EmailHandler {
@JobWorker(type = "send-email", maxJobs = 5, lockDuration = "1m")
public Vars handle(Job<EmailJob> job) {
emailService.send(job.typed().recipient(), job.typed().subject());
return new Vars().set("messageID", "msg-123");
}
public record EmailJob(String recipient, String subject) {}
}
The autoconfig scans every Spring bean for @JobWorker methods, infers the typed payload from Job<T>, and starts/stops a managed worker via SmartLifecycle.
In this tutorial an AI coding agent builds a Spring Boot claims API on a deployed process with the starter, and checks it against the engine with dry runs first.
Deploy models on startup
@Deployment on any bean class, typically the application class, deploys the matching BPMN and DMN files when the application starts:
@SpringBootApplication
@Deployment(resources = {"classpath*:models/*.dmn", "classpath*:models/*.bpmn"})
public class LoanApplication { }
The patterns are Spring resource patterns, and each matched file must end in .dmn or .bpmn. Each file is saved under its file name and deployed. All DMN files deploy before the BPMN files, so a process never starts before the decisions it calls exist, and both deploy before the job worker starts.
- A file whose XML is identical to the latest deployed version of its
<definitions id>is skipped, so a restart deploys only what changed. - When several instances start at once, the first deploy of a file wins. The others remove their drafts.
- A pattern that matches no file, a file of another type, or a model the server rejects fails startup. A rejected draft is removed.
The server compares a file with the latest deployed version only. An instance still running older XML deploys it again as a new version when it restarts, for example during a rolling update. Set quantumbpm.deployment.enabled: false to skip the deploy, for example where a pipeline deploys the models.
Authentication
ClientCredentialsTokenProvider fetches tokens from your OIDC identity provider with the client credentials grant. The three-argument constructor takes the token URL, client ID and client secret. A second constructor adds scopes and an audience:
var provider = new ClientCredentialsTokenProvider(
"https://idp.example.com/realms/acme/protocol/openid-connect/token",
"billing-svc",
System.getenv("QUANTUMBPM_CLIENT_SECRET"),
List.of("openid"), // scopes, may be empty
"quantumbpm"); // audience, may be null
The Spring Boot starter reads the same values from quantumbpm.auth.client-credentials.token-url, .client-id, .client-secret, .scopes and .audience. It uses the client credentials provider when token-url and client-id are set, and the static quantumbpm.token otherwise.
The exact token endpoint depends on the identity provider, see Authentication. A failed token request throws TokenException with the HTTP status and response body. For a token you already hold, use new StaticTokenProvider(token).
Deploy a DMN definition
var draft = client.dmn().createDefinition("loan-eligibility", dmnXml);
var deployed = client.dmn().deployDefinition(draft.getId());
var result = client.dmn().evaluate(deployed.getDefinitionsID(), new Vars().set("requestedAmt", 5000));
A draft is not evaluable until it is deployed, and the deploy gives it the next version of its <definitions id>. Saving XML identical to the latest deployed version throws ApiException with code 409, and nothing is saved.
Correlation keys (businessId)
Stamp a caller-supplied correlation key (order number, ticket ID, etc.) on a new instance by passing it as the third argument to startInstance. The key is inherited by every child instance, external job, user task, and DMN execution emitted by the process - workers read it as job.businessId().
client.bpmn().startInstance("loan-process", vars, "ORDER-42");
// Filter listings by the same key.
var page = client.bpmn().listInstances(null, null, null, null, null, null, "ORDER-42", null, null, null);
var tasks = client.bpmn().listUserTasks(null, null, null, null, null, "ORDER-42", null, null);
// DMN evaluations stamp it on the resulting execution row.
client.dmn().evaluate("loan-eligibility", vars, DmnClient.withBusinessId("ORDER-42"));
External job workers (without Spring)
import com.quantumbpm.client.workers.BpmnError;
import com.quantumbpm.client.workers.Worker;
Worker worker = client.newWorker("billing-svc");
worker.handle("send-email", job -> {
String recipient = job.vars().get("recipient", String.class);
emailer.send(recipient);
return new Vars().set("messageID", "msg-123"); // → Complete
}, Worker.withMaxJobs(10), Worker.withLockDuration("1m"));
worker.start(); // returns immediately, loops run on virtual threads
Runtime.getRuntime().addShutdownHook(new Thread(() -> worker.stop(20_000)));
worker.awaitTermination(); // blocks until stop returns
Virtual threads do not keep the JVM alive, so main waits on awaitTermination().
Heartbeats keep each job locked to the worker while its handler runs. The server clamps lockDuration to 10s..5m by default, and the worker heartbeats at half of the lock it was granted. Durations are Go duration strings such as 500ms, 30s, 12.5s or 1m30s, and an invalid one throws IllegalArgumentException from handle. When a heartbeat finds the lock gone, the handler thread is interrupted and nothing is reported for that job. stop(timeoutMillis) stops polling, and running handlers keep heartbeating and report their results until the timeout. Handlers still running then are interrupted and not reported, so blocking handlers should respond to interrupts. A job abandoned that way costs a retry, see When a lock runs out. The Spring starter stops its worker with a 20s timeout. On Kubernetes, keep terminationGracePeriodSeconds above it.
Throw a BpmnError to fail with a code boundary error events can catch:
throw new BpmnError("INSUFFICIENT_FUNDS", new Vars().set("balance", 12.0));
Any other thrown exception is reported with the code WORKER_ERROR and the message attached as the error variable (truncated to 2048 bytes by default, raise via the maxErrorMessageBytes parameter on the Worker constructor). A boundary error event whose error definition has errorCode="WORKER_ERROR" catches it once the retry budget is exhausted - see Failure handling.
For typed dispatch outside Spring, pass the type as the second argument:
record EmailJob(String recipient, String subject) {}
worker.handle("send-email", EmailJob.class, job -> {
emailer.send(job.typed().recipient());
return new Vars();
});
Full reference
See the SDK README for the complete API surface, the Vars typed-access helpers, and the Spring Boot configuration reference.