What is the difference between `customHeaders` and `variables` in an `ActivatedJob`

I came across these terms while studying the gateway proto file:

What is the difference between these two fields, and when do I use them?

Variables are the keys of the job’s state object.

Custom Headers are a key:value object that is defined on the task instance. I demonstrate this at the end of this video: https://youtu.be/xjzwUq-tHXE (15m 22s in).

So you can genericize a task worker for a task type, and pass custom metadata to from the task instance in a BPMN process to modify its behaviour. I use it to drop console.log('I am at ' + job.customHeaders.breakpoint) in a process flow. You can use a single worker / task-type to emit information about specific tasks that way.

Maybe not the ultimate use case, but the first thing that came to my mind.

Thanks for pointing me the video. I think it’s a little more clear now.

I think if I had to explain the difference to someone else, I may use different terminology. Both custom headers and variables are data available in an activated job.

Correct me if I’m wrong, but it seems that custom headers are static in the sense that it does not change between workflow instances.

Variables are dynanmic/runtime data. They change between workflow instances.

Custom headers are not static to the job type because you could hypothetically have two different bpmn processes that are the same job-type but different custom headers.

1 Like

Yes, custom headers are static to the task element instance.

I think of variables as the job state. Zeebe is kinda like a Redux store, and the workers are state reducers.

1 Like