Retry with different behavior

If we have an activity that communicate with https://server-1.com (for example)
if request fails for any reason, we need to fail the activity & retry but with https://server-2.com (for example)

Is that achievable with Temporal?

Some ways to achieve this:

  • The activity itself can decide which server to communicate to based on how many times it was invoked. Use activity.GetInfo(ctx).Attempt to learn this.
  • Disable automatic activity retries and retry from the workflow code. This allows specifying new activity arguments on every retry. Be careful with retrying from workflow many times as each retry would increase a workflow history size.

Given that our activity is running in a session (so each retry will be done on same worker)
Can we use activity.RecordHeartbeat to preserve some state between retries?
We don’t set HeartbeatTimeout, So heartbeats won’t be send to the Temporal Server as I get from docs

The question is: As we’re running in a session, if activity retry called activity.GetHeartbeatDetails Will it be able to get the details recored by previous run on the same worker although HeartbeatTimeout is not configured?

I believe details are flushed before reporting an activity failure. But I’m not sure if heartbeat timeout is still required.