Skip to content

Commit

Permalink
docs: document job result in Job Workers concept page
Browse files Browse the repository at this point in the history
- Added a short section on job results in `completing or failing jobs`.
- Linked to the `User task listeners` concept page
- Added note that job result is used for the user task listeners only right now.

Co-authored-by: Ana Vinogradova <[email protected]>
  • Loading branch information
ce-dmelnych and ana-vinogradova-camunda committed Jan 2, 2025
1 parent 1f6555a commit f0b6578
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/components/concepts/job-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,43 @@ There are several advantages when failing a job with variables. Consider the fol

:::

### Using job result

For [user task listeners](components/concepts/user-task-listeners.md) job workers can provide a **job result**.

Job results are used to define:

1. **Corrections**: Updates to specific user task attributes, such as assignee, due date, follow-up date, candidate users, candidate groups, and priority, before the task transition is finalized. For more details, see [Correcting user task data](components/concepts/user-task-listeners.md/#correcting-user-task-data).
2. **Denial**: Indicates that the operation should be explicitly denied. Denying an operation prevents the task lifecycle transition and discards any corrections made by previous listeners. For more details, see [Denying the operation](components/concepts/user-task-listeners.md/#denying-the-operation).

Below is an example of using job result:

```java
final JobHandler userTaskListenerHandler =
(jobClient, job) -> {
boolean shouldDeny = someValidationLogic(job);

jobClient
.newCompleteCommand(job)
// highlight-start
.withResult(
new CompleteJobResult()
.correctAssignee("john_doe")
.correctPriority(42)
.deny(shouldDeny)) // deny based on validation logic
// highlight-end
.send();
};
```

If both corrections and denial are provided in the same job result (for example, `.correctAssignee(...)` and `.deny(true)`), the job completion command will be rejected. To avoid this, ensure the job is either completed with corrections (without denial set to `true`) or denied (without corrections).

:::info

The `corrections` and `deny` features are currently available only for user task listener jobs.

:::

## Timeouts

If the job is not completed or failed within the configured job activation timeout, Zeebe reassigns the job to another job worker. This does not affect the number of `remaining retries`.
Expand Down

0 comments on commit f0b6578

Please sign in to comment.