Job filtering based on variables value does not support by default in Camunda 8, we need to try alternatives like acquire all jobs and complete only which meets filter criteria.
Hi @matt ,
Can you help me understand?
Why would you want your worker to only take some of the work that it is capable of doing? To me that would be like saying “Forklift driver, move all the boxes from Point A to Point B, but only if the box is Blue” If the forklift driver isn’t qualified to move Blue boxes, then it’s a different type of work and should have a different worker, shouldn’t it?
For RuntimeException you shouldn’t be handling through ZeebeBpmnError. When technical error occurs just log the exception and rethrow it so the incident will get created. You can retry for few exceptions like timeout or network related exceptions.
ZeebeBpmnError mainly used to handle business errors and when thrown it should be handled in workflow, otherwise it makes no sense by just throwing ZeebeBpmnError.
To elaborate:
When to Use ZeebeBpmnError
ZeebeBpmnError is intended only for business exceptions that:
Are expected as part of the process logic (e.g., “Invalid Credit Score”, “Stock Not Available”).
Are handled explicitly in the BPMN model using an Error Boundary Event with a matching errorCode.
Example:
if (!isCustomerEligible(customer)) {
throw new ZeebeBpmnError("CUSTOMER_INELIGIBLE", "Customer does not meet eligibility criteria");
}
This throws a business error, which must be caught in the BPMN via an error boundary event:
Service Task --> (boundary error event with errorCode="CUSTOMER_INELIGIBLE") --> Alternative Path
If there’s no boundary event for that error code, then the error will cause an incident anyway — which defeats the purpose.
When Not to Use ZeebeBpmnError
Don’t use it for technical exceptions such as:
NullPointerException
Network timeouts
Database errors
REST call failures
Instead:
Log the error.
Let the worker fail naturally by rethrowing the RuntimeException.
This way:
Zeebe will trigger incident handling.
You can inspect the root cause in Operate.
Retry behavior can be configured using retry count/backoff/etc.
So we have essentially an integration layer that acts as a common interface to several different implementations of a service. We have a set of core workers that can handle all the common bits, but due to dependency conflicts of third party libraries we need to use, each implementation workers are defined in their own micro services.
As there is only the need for one workflow, in camunda 7 the easiest way to achieve the correct worker picking up the job was with the variable filtering.
Unfortunately this is no longer an option in camunda 8 so we are going to use FEEL to create the worker type by concatenating the variables to the type definition and do the same in the code of the micro services.
@matt
I recall something about the workers being able to be tenant aware, so you could have the workflow created for each tenant, and then have the appropriate version picked up.
But realistically, if it’s a different set of work, it should be a different worker.
I dont think you can achieve it with Camunda up to the 8.7.
If you take a look on Zeebe job activating API: Zeebe API RPCs | Camunda 8 Docs then there’s no way to filter jobs that will be acquired besides the job type. You could use multi tenancy feature to achieve your goal, but it will require some changes in the BPMN model, so i guess you could as well just create dedicated job types instead of filtering it by variables.