Implement partial Activities in a Workflow

Hello, I don`t know if such topic exists, but I have one question…
Is it possible to implement a single activity in a Workflow?

In a example that I’m struggling… I have a Workflow with 10 activities… And I want to deploy 11 workers, 1 to deal with the workflow, and 10 to deal with the activities, with each worker implementing a single activity. When I do this, each worker will poll the Task Queue and most of the time, they will fail, with messages like “I do not have any implementations for Activity FooBar, implementations available are MyCustomActivity…”. I didn’t find any config to tell a worker to only poll tasks for it’s registered activities… there is any way to do that?

I’m using the Java SDK.

(Sorry for being vague with descriptions, I’m not near the code at the moment)

From the issue you are describing I assume you currently have all workers listening on the same task queue. What’s happens is when server places the task on task queue any worker thats listening on it can pick it up (it’s random) and it just says it does not have the activity registered to process this task.
Server is then going to place this task on task queue again and this would go on until a worker that has the activity actually registered picks it up.

A single worker process can process many workflows and activities. If all your activities run on the same task queue, then all worker processes that listen to it should have the activity registered.

Temporal does supports task queue rate limiting across multiple worker processes. If you want to rate limit a specific activity have it listen on its own task queue and set WorkerOptions.setMaxTaskQueueActivitiesPerSecond to N to get N activities per second rate limit.

Thanks @tithomir for answering!

From the issue you are describing I assume you currently have all workers listening on the same task queue. What’s happens is when server places the task on task queue any worker thats listening on it can pick it up (it’s random) and it just says it does not have the activity registered to process this task.
Server is then going to place this task on task queue again and this would go on until a worker that has the activity actually registered picks it up.

Yes, this is exactly what happens. And everytime the process fails due to Activities not present, the timeout for the task be picked goes up (that is configured in my workflow).

A single worker process can process many workflows and activities. If all your activities run on the same task queue, then all worker processes that listen to it should have the activity registered.

So every worker in a task queue should implement all activities, ok. Can I use multiple Task Queues in a single workflow to fulfil my requeriments from the topic example proccess (it is just a experiment project)?

In my case I’m testing the possibilities of various different teams creating workers that implement some activities reused in different workflows, in other word those workers wont’ have the full list of required activities in the task queue.

Temporal does supports task queue rate limiting across multiple worker processes. If you want to rate limit a specific activity have it listen on its own task queue and set WorkerOptions.setMaxTaskQueueActivitiesPerSecond to N to get N activities per second rate limit.

I see. For now I’m not testing Rate Limiting, but I’ll remember this when testing.

Can I use multiple Task Queues in a single workflow to fulfil my requeriments from the topic example proccess

In your client code you set the task queue for workflow via WorkflowOptions. Inside your workflow code you can set a different task queue in ActivityOptions. You can also set per-activity options via WorkflowImplementationOptions, see sample here.

In my case I’m testing the possibilities of various different teams creating workers that implement some activities reused in different workflows

This is a great benefit you get from using Temporal. Each team can write their workflows / activities in different programming languages as well (that Temporal has SDKs for), see this video for more info.
Just note that currently there is no way to invoke an activity in a different namespace. In the case where each team works in its own namespace they would need to expose a workflow that you can invoke (as child workflow for example from your workflow).

1 Like