Possibility to specify worker instance that receives the job

Hello

In our team we have many worker instances of same type running on different servers. Since these workers run scripts that deal with filesystem and other components installed on these VMs, we need a way to specify in BPMN model which worker instance (on which VM) will run the script. We haven’t found a way to instruct Zeebe which worker instance should the task be assigned to (or maybe there is such feature?) so we tried to use some work-around - pass worker instance ID in a header and when the worker receives the job, compare the ID from the header with configured worker ID. If they are not equal - worker sends job failed and zeebe retries the job, hoping this time it will be assigned to the right worker instance. The issue with this work-around is that the broker may keep retrying/reassigning the job to the same worker (as we run some tests it can retry on the same worker for hundred times before switching to some other instance…). Is there any better way to solve our problem?

Hello @mati76 ,

in this case, I would not use the same job type for all of your workers.

You could for example define a mechanism where a script-to-be-executed is registered with a job type, leading your worker implementation to subscribe for the execution of this specific script only.

What do you think?

Jonathan

Yes, I was thinking about using job type to specify which instance should be used for running some scripts. Then in my bpmn model I could choose “run-bash-1” job type if I want my script to run on worker instance #1 or “run-bash-2” if it should run on another. This should work but then choosing the right instance becomes mandatory - it won’t be possible to run a script on any of available workers. In our current setup you just pick “run-bash” worker and define a script you want to run, then if needed, you can specify on which worker instance the script should be running.

Hello @mati76 ,

in this case, you could adjust the way you define a job type:

run-bash would run on any version.
run-bash:1 would only run on version 1
run-bash:2 would only run on version 2

Here, the requirement would be that each worker subscribes to 2 job types: the versioned one and the unversioned one.

What do you think?

Jonathan

hmm, sounds great :slight_smile: I wasn’t aware that worker can subscribe to more than one job type. Thank you, I will try this out!

Hello @mati76 ,

depending on the implementation, I am not sure whether this can be done easily using spring-zeebe for example.

The principle is that multiple subscriptions share the same handler function.

Jonathan