The execution listener for a user task node in Camunda 8 fails to fetch custom headers

My user task node is defined as follows:

<bpmn:userTask id="Activity_0axedj2" name="apply">
  <bpmn:extensionElements>
    <zeebe:userTask />
    <zeebe:formDefinition externalReference="abc" />
    <zeebe:taskHeaders>
      <zeebe:header key="a" value="a" />
      <zeebe:header key="b" value="b" />
    </zeebe:taskHeaders>
    <zeebe:executionListeners>
      <zeebe:executionListener eventType="end" retries="3" type="counter-sign-event" />
    </zeebe:executionListeners>
  </bpmn:extensionElements>
  <bpmn:incoming>Flow_19bp0t6</bpmn:incoming>
  <bpmn:outgoing>Flow_0zhppsq</bpmn:outgoing>
</bpmn:userTask>

But when the execution reaches the counter-sign-event event, I found that the customHeaders property in ActivateJob is empty.

How can I correctly access the configured header values?

Hi @jamesxql ,

In Camunda 8, especially when using Zeebe (the workflow engine behind Camunda 8), execution listeners like those in Camunda 7 do not work the same way. If you’re using user tasks, you’re likely working with task listeners or custom workers, and here’s the clarification:

Key Points:
1. Zeebe does not support BPMN execution listeners in the way Camunda 7 does.
2. Custom headers (defined in the BPMN model) are only accessible by external task workers, not by listeners.
3. For user tasks, you’re likely using task forms and task lifecycle events, and any business logic should be handled outside of Zeebe, like in your tasklist listener or task workers.

If you’re trying to access custom headers in a worker:

Make sure you’re using a Job Worker (Java, Node.js, etc.) for a service task, not a user task. Example (Java Zeebe client):

job.getCustomHeaders().get("your-header-key");

This works only in job workers, not listeners.

If you’re trying to react to a user task (e.g., task created):

You need to subscribe to Tasklist APIs or use Operate’s or Tasklist’s event streams to respond to lifecycle events (like task created, completed). But you won’t have access to custom headers because those apply only to job workers.

Alternatives / Workaround:

If you want to pass metadata with user tasks:
• Use input/output mappings to pass variables instead of custom headers.
• Use task form metadata or form fields.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.