Result
Awaiting jobs and reading typed results.
Awaiting jobs and reading typed results.
String id = flexiq.enqueue(add, payload);
flexiq.awaitJob(id, Duration.ofSeconds(30)); // block until terminal
Optional<Integer> sum = flexiq.getResult(id, Integer.class); // 5awaitJob(id, timeout) polls the store until the job reaches a terminal state
(COMPLETE, DEAD, or CANCELLED) and returns its Optional<Job> snapshot;
it throws a FlexiQException if the timeout elapses first. Any process
sharing the storage can await a job by id.
| Method | Description |
|---|---|
getResult(id) → Optional<byte[]> | The raw serialized result, if complete. |
getResult(id, Class<R>) → Optional<R> | The result deserialized with the queue's serializer. |
Both return Optional.empty() while the job is still pending or running — pair
them with awaitJob (or an EventName.SUCCESS listener on the worker) when
you need to block.
Job snapshotgetJob(id) returns the job's current state without waiting:
flexiq.getJob(id).ifPresent(job -> {
System.out.println(job.status); // JobStatus.RUNNING
System.out.println(job.progress); // 0–100, if reported
System.out.println(job.error); // last error, if any
});Job carries id, queue, taskName, status, priority, createdAt,
scheduledAt, startedAt, completedAt, retryCount, maxRetries,
timeoutMs, progress, error, uniqueKey, namespace, and metadata.
All timestamps are Unix milliseconds.
awaitJob is for waiting on one job (tests, request/response bridges). To
scan many jobs use listJobs(JobFilter); for aggregate outcomes use
metrics(taskName, sinceMs).