Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document job result in Job Workers concept page #4813

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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

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 lifecycle transition should be explicitly denied. Denying the task lifecycle transition rolls back the user task to the previous state, 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
10 changes: 5 additions & 5 deletions docs/components/concepts/user-task-listeners.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ Currently, user task listeners support the following events:

Each user task listener has the following properties:

| Property | Description |
| :---------- | :------------------------------------------------------------------------------------------------------------ |
| `eventType` | Specifies the user task event that triggers the listener. Supported values are `assigning` and `completing` . |
| `type` | The name of the job type. |
| `retries` | The number of retries for the user task listener job. |
| Property | Description |
| :---------- | :----------------------------------------------------------------------------------------------------------- |
| `eventType` | Specifies the user task event that triggers the listener. Supported values are `assigning` and `completing`. |
| `type` | The name of the job type. |
| `retries` | The number of retries for the user task listener job. |

:::note
If multiple user task listeners of the same `eventType` (such as multiple `assigning` listeners) are defined on the same user task, they are executed sequentially, one after the other, in the order they are defined in the BPMN model.
Expand Down
Loading