Can workers avoid picking up tasks if their dependencies are down?

I have a CassandraActivity which does all the C* work for my app. I have a specific Worker and TaskQueue that are only used for CassandraActivity.

Let’s say I have two instances deployed, and the connection to C* goes down on one of those instances. If I was using a synchronous API instead of Temporal, I could have the instance mark itself as UNHEALTHY, and a VIP could stop sending traffic to that instance as long as C* down. Is there an equivalent in Temporal, where the worker for CassandraActivity stops picking up tasks as long as its critical C* dependency is unhealthy?

I understand that even if a worker picks up a CassandraActivity task and it fails, there’s no harm done. The activity will retry on various workers until it eventually passes. However, I’m trying to figure out if there’s a way to avoid this failure in the first place.

With Java SDK workers have two methods suspendPolling and resumePolling that you could use.

Depending on your global condition you could suspend your activity worker(s) and then resume again when applicable.

Great, thank you, this is what I was looking for. A related question - is there guidance on distributing activities and workflows across workers? In a case like this one, it seems like only having C* activities on a specific worker is beneficial because you can prevent all polling if the resources is down. If the activities and workflows don’t depend on a resource like in this example, is there a recommendation?

Work can be distributed however you see fit via additional task queues. We route specific activities & workflows to dedicated workers via this.

1 Like