What is the underlying reason why all workers listening to the same task queue must be registered to handle the same workflow types and activity types?

Hello! We’re getting started with Temporal and as we’ve begun to work through some of the concepts and build out a few simple workflows (in Java), we ran into the following constraint called out in the task queue documentation: Temporal Java SDK developer's guide | Temporal Documentation

All Workers listening to the same Task Queue name must be registered to handle the exact same Workflows Types and Activity Types.

This is also called out here in the concepts doc: What is a Temporal Worker? | Temporal Documentation

All Workers listening to a given Task Queue must have identical registration of Activities/Workflows.

Anyway, this is all fine and we’ve updated our understanding accordingly, but can you explain a little bit more as to why? Is there a registration happening under-the-hood when a worker starts up, and Temporal server is recording which worker has come up to listen to task queue ABC for work of types D, E, F? I was under the (mistaken) impression that task work could be routed to the appropriate worker based on what work it wanted to work on (what work it registered for).

@dpincas a worker is registered to a specific task queue (you can think of it as an end-point for example). workers are hosted by your infrastructure and use long-polling to communicate to the Temporal server. When the server places a workflow task onto a queue, one of the workers (registered to listen to that queue) picks it up and processes it. The statement in the mentioned docs mean that if you have multiple worker processes that are listening on the same task queue, when a new workflow task is placed onto that queue that all of them are listening to, any of those could pick up that task to work on it. In that case all of them should have the workflows/activities registered in order to process that task.

You can definitely still do routing, as shown in this sample.

I would also recommend watching this video which has a great explanation of workers and task queues.

Hope this helps.

1 Like