Rate limit activities


How can I rate limit on a specific activity which is part of a workflow. Can you please share some code examples ?
For Example: Workflow has activities A, B, C, D. How can I configure to say at any instant the activity A should only be invoked twice in a span of 1 second ?

Temporal supports task queue rate limiting across multiple worker processes. If you want to rate limit a specific activity then make sure that it listens on its own task queue by creating a separate worker object instance. Then set WorkerOptions.MaxTaskQueueActivitiesPerSecond to 2 to get 2 activities per second rate limit.

Thanks @maxim How can I unit test to make sure the number of activities invoked are indeed the specified count ? Is there a junit support or any other way to validate this programmatically or manually ?

You have to test it against the real service (docker-compose one is OK). I don’t think unit testing work for this scenario.