Task Listener Elastic Search Exporter

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:

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:

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.