Hi Team,
Do we have any example where I can find Elastic Search Exporter used for Tas Listener events captured and perform some email sending use case or any other use cases ?
Hi @vinothkumar ,
I don’t have a full example. However, I’ve a Java snippet for an exporter reacting to user tasks.
package io.camunda.forum;
import io.camunda.zeebe.exporter.api.Exporter;
import io.camunda.zeebe.exporter.api.context.Context;
import io.camunda.zeebe.exporter.api.context.Controller;
import io.camunda.zeebe.protocol.record.Record;
import io.camunda.zeebe.protocol.record.ValueType;
import io.camunda.zeebe.protocol.record.value.BpmnElementType;
import io.camunda.zeebe.protocol.record.value.JobRecordValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CustomUserTaskExporter implements Exporter {
public static String USERTASK_JOB_TYPE = "io.camunda.zeebe:userTask";
public static String ELEMENT_COMPLETED = "ELEMENT_COMPLETED";
private Controller controller;
private final Logger log = LoggerFactory.getLogger(CustomUserTaskExporter.class);
@Override
public void configure(Context context) throws Exception {
context.setFilter(new CustomUserTaskFilter());
Exporter.super.configure(context);
}
@Override
public void open(Controller controller) {
Exporter.super.open(controller);
this.controller=controller;
}
@Override
public void close() {
Exporter.super.close();
}
@Override
public void export(Record<?> record) {
if (record.getValueType().equals(ValueType.JOB) &&
((JobRecordValue)record.getValue()).getType().equals(USERTASK_JOB_TYPE)) {
// the process reached a user task
JobRecordValue jobValue = (JobRecordValue)record.getValue();
String userTaskId = ((JobRecordValue)record.getValue()).getElementId();
log.info("Starting user task {}.",
userTaskId, processVariables, taskVariables);
}
this.controller.updateLastExportedRecordPosition(record.getPosition());
}
}
I hope that this helps you developing your own exporter.
Kind regards
Stephan
Hi @StephanHaarmann ,
My use case is, when I am claim/assigning task, I need to trigger email/separate db insertion.
I am not sure how above code will help my use case. Can you plz give bit explain how can I achieve
Hi @vinothkumar ,
In this case, you’re right - my example does not help. It only allows you to detect that a user task has been started but not that it has been assigned or claimed. I believe that claiming user tasks is not handled by zeebe, but by tasklist. Hence, there is no event. However, this will change in the next release:
opened 09:00AM - 08 Dec 23 UTC
closed 11:45AM - 21 Dec 23 UTC
scope/broker
component/engine
component/broker
kind/task
version:8.4.0
**Description**
* Implement a processor for the `UserTaskIntent.CLAIM` comman… d issued for the `UserTask` value type.
* Ensure the user task can be claimed, i.e. it is in the internal state CREATED and the task's assignee is either ~`null`~ an empty String or the same as the assignee provided by the command. Otherwise, write a rejection for the command.
* For adjusting the assignee, reuse the `assign` command functionality provided with https://github.com/camunda/zeebe/issues/15529
@koevskinikola: I updated the description to state that the assignee can be an empty String instead of `null` since gRPC doesn't allow `null` values.
opened 09:00AM - 08 Dec 23 UTC
closed 08:03AM - 15 Dec 23 UTC
scope/broker
component/engine
component/broker
kind/task
version:8.4.0
**Description**
* Implement a processor for the `UserTaskIntent.ASSIGN` comma… nd issued for the `UserTask` value type.
* Ensure the user task can be assigned, i.e. it is in the internal state CREATED. Otherwise, write a rejection for the command.
* Emit `UserTask.ASSIGNING` and `UserTask.ASSIGNED` events on the event stream.
* Processing the `UserTask.ASSIGNING` event sets the user task's internal state to `ASSIGNING`. This prevents other actions while the task is being assigned.
* Processing the `UserTask.ASSIGNED` event sets the user task's assignee accordingly and sets the user task's internal state to `CREATED` to allow for new actions.
Thanks for the update @StephanHaarmann
May I know when this release is planned ?
And just curious to know we are covering only Claim, Assigning or we are covering all the lifecycle events which is available in Camunda 7 as Create, Assign, Complete, delete, update, timeout ?
According to the documentation , the release is planned for next week (01/09/2024).
Some events, such as complete and delete, are already covered by the usual BPMN element lifecycle events.
Update is planned, but not yet implemented.
I don’t know about timeout.
You can track the progress via this epic:
opened 08:49AM - 08 Dec 23 UTC
scope/broker
kind/epic
component/engine
component/exporter
component/broker
## Introduction
Provide the additional user task lifecycle actions in the bro… ker that emit new events on the event stream.
This enables more use cases for user tasks, allowing users to assign and update them.
## Concept
The general technical concept is described in the [(🔒 internal) User Task lifecycle & listeners in Zeebe](https://docs.google.com/document/d/1RUGoofgrSz1pFYKEBDjUggaz8fDeBkkJEv8KSl2fJBM/edit#heading=h.jfwkcbaivk7y) as increment [5](https://docs.google.com/document/d/1RUGoofgrSz1pFYKEBDjUggaz8fDeBkkJEv8KSl2fJBM/edit#heading=h.nkx4pi1zpa1d).
In short:
* We prepare the following actions as commands in the broker:
* Assign - Set the assignee without a check of a potentially existing assignee. To be used when a user or machine assigns another user to a task
* Claim - Set the assignee. If the assignee is already set, reject. To be used to claim a task for myself from a working queue (e.g. with multiple candidates).
* Update - Updates supported attributes of a task.
* The commands issue new events:
* ASSIGNING & ASSIGNED
* UPDATING & UPDATED
* (optional) The commands allow setting a custom `action` attribute in the user task to enable custom lifecycle implementations on top of our general actions.
## Task Breakdown
<!-- When splitting the Epic into smaller issues, they should be referenced here. This provides an
easy overview of all that needs to happen. It also provides a good overview of the progress on the
Epic thus far. -->
```[tasklist]
### Preparation
- [ ] https://github.com/camunda/zeebe/issues/15528
```
```[tasklist]
### Broker
- [ ] https://github.com/camunda/zeebe/issues/15529
- [ ] https://github.com/camunda/zeebe/issues/15530
- [ ] https://github.com/camunda/zeebe/issues/15531
- [ ] Support a customizable `action` attribute in user task commands
```
### Out of scope
* Providing external API will be done with https://github.com/camunda/zeebe/issues/15622 and is out of scope here
## Other Teams
<!-- The Epic might have an impact on other teams within Camunda. We should create an issue for
them, explaining the changes they will have to make. -->
The following teams are aware through (🔒 internal) https://github.com/camunda/product-hub/issues/1823:
- [x] [Operate](https://github.com/camunda/operate/issues)
- [x] [Tasklist](https://github.com/camunda/tasklist/issues)
- [x] [Web Modeler](https://github.com/camunda/web-modeler/issues)
- [x] [Desktop Modeler](https://github.com/camunda/camunda-modeler/issues)
- [x] [Optimize](https://github.com/camunda/camunda-optimize/issues)
## Discussions and Decisions
<!-- A place to write down discussions and decisions that have been made. Ongoing discussions should
also be added here. This makes it transparent what is going on with this Epic. -->
## Links
<!-- Any links to resources that could provide additional context to this Epic. For example, the
Camunda 7 documentation. -->
- Product Hub (🔒 internal): https://github.com/camunda/product-hub/issues/1823
Hi @StephanHaarmann ,
Hope 8.4 released. I don’t find this issue as part of this release ?
Can you please help me to understand if this is got release or not ?
Hi @StephanHaarmann ,
Can you help on this ?
Hi @vinothkumar ,
my experiments show that this feature has not been released. I don’t see events or command related to claiming or assigning a user tasks on the record stream. While the event types are already implemented, I think they are not yet raised.
Okay. Fine @StephanHaarmann ,
Thanks for your response.
Any idea when it can be released ?
Hi @vinothkumar ,
I checked once again internally. The events are already implemented and availalbe in the 8.4 release. However, they are only raised for user tasks with a specific extension element:
<userTask id="task" name="task">
<extensionElements>
<zeebe:userTask/>
</extensionElements>
<incoming>sequenceFlow_f87da8da-ce50-40f9-abb9-21efc2b81703</incoming>
<outgoing>sequenceFlow_839d6cf7-456e-493a-b24c-e8b61e72b60c</outgoing></userTask>
The feature is not yet complete – some events and an API to send corresponding Commands are missing. Also, user tasks with this anntoation won’t be visible in Tasklist.
I don’t know when these features will be fully implemented and released.
Hi @StephanHaarmann ,
Any update on this. Can you plz give me the sample project if already somewhere Task listener is implemented
Hey @vinothkumar I was going through the same use case , could you please provide any leads or updates if you found any.
ThankYou In Advance
Mukesh
Hi @StephanHaarmann ,
Hope you are doing well. I would like to follow up with you on this. Do you have any example where I can see and understand on the implementation part ?
Hi @StephanHaarmann , Do I need to build this & need to start along with my zeebe broker. Is there any way directly I can find the events in the spring boot ?
Hello @vinothkumar ,
I’m sorry for responding so late - I’ve been out of office.
Your understanding is correct: A custom exporter needs to be compiled and loaded into the Zeebe broker.
This being said: Camunda’s engineers are actively working on User Task Listeners that will allow you to subscribe to events from the Spring Boot SDK:
You can check the following Github Epic to track the progress:
opened 12:32PM - 05 Sep 24 UTC
kind/epic
component/zeebe
## Introduction
Currently, Tasklist doesn’t provide any events describing wha… t is happening in tasks.
This blocks technical use cases that require visibility into task state changes, such as managing tasks in a custom task list, assigning users based on custom logic or notifying users about new tasks.
Working with user tasks produces multiple lifecycle events, where each of them might be important to react to. With the current solution, customers need to consume lifecycle events (available only in Self-Managed) in their systems and react to events in a specific way. This is a problem as to satisfy this need customers have to provide additional infrastructure (to consume and store events), filter Zeebe events and react to specific ones. This approach might work only in self-managed installations with a custom Tasklist application.
The lack of this functionality prevents satisfying some HTO use cases where customers need to react to lifecycle events.
This epic addresses the need to unlock multiple human task orchestration use cases.
## Task breakdown
```[tasklist]
### Iteration 1 - Blocking Complete Listener E2E increment - Target End of September
- [ ] https://github.com/camunda/camunda/issues/21491
- [ ] https://github.com/camunda/camunda/issues/21975
- [ ] https://github.com/camunda/camunda/issues/21976
- [ ] https://github.com/camunda/camunda/issues/21977
```
```[tasklist]
### Iteration 2 - Iterate on the complete listener - Target 8.7.0-alpha1
- [ ] https://github.com/camunda/camunda/issues/22398
- [ ] https://github.com/camunda/camunda/issues/23925
- [ ] https://github.com/camunda/camunda/issues/24101
- [ ] https://github.com/camunda/camunda/issues/24056
```
```[tasklist]
### Iteration 3 - Assignment listener + listener abilities - Target 8.7.0-alpha2
- [ ] https://github.com/camunda/camunda/issues/24197
- [ ] https://github.com/camunda/camunda/issues/23709
- [ ] #23728 (will be worked using the same issue and branch between Operate BE and FE)
- [x] #23383 (bugfix for Execution Listeners that will be worked as part of this epic)
- [ ] #23942
- [ ] #23944
- [ ] #23945
- [ ] #23946
- [ ] https://github.com/camunda/camunda/issues/23492
- [ ] #23941
- [ ] #23943
```
```[tasklist]
### Iteration 4 - Feature wrap up - Target 8.7.0-alpha3
- [ ] https://github.com/camunda/camunda/issues/23708
- [ ] https://github.com/camunda/camunda/issues/24102
- [ ] Add documentation on User Task Listeners (for 8.7)
- [ ] Expose User Task properties to job worker client
- [ ] https://github.com/camunda/camunda/issues/24107
- [ ] Potential space for stretch goals
```
```[tasklist]
### Out of scope (stretch goals)
- [ ] Task Listener for `create` operation
- [ ] Task Listener for `update` operation
- [ ] Task Listener for `cancel` operation
- [ ] https://github.com/camunda/camunda/issues/22717
- [ ] https://github.com/camunda/camunda/issues/23702
- [ ] https://github.com/camunda/camunda/issues/24607
```
## Links
- Issue: https://github.com/camunda/product-hub/issues/1822
- Root epic: https://github.com/camunda/product-hub/issues/1316
- Operate design: [Figma](https://www.figma.com/proto/zfOVIMNthZneqFiyUhWTP2/Listeners?page-id=925%3A34385&node-id=856-29596&node-type=frame&viewport=-986%2C-1810%2C0.08&t=MXwMMnjHSWn6Jqq6-1&scaling=min-zoom&content-scaling=fixed&starting-point-node-id=856%3A29596)