How to change input for failed activity and retry it again


In my case while activity gets failed, I need to retry the same activity with new inputs.
Does Temporal provides that feature in JAVA-SDK.

Activity retries are limited by the activity ScheduleToClose timeout (and if not specified, by the workflow run timeout).
You can also set RetryOptions for activities and can limit the number of max attempts for example (by default set to unlimited). See this sample for reference.

I think for your question you could:

  1. Define it as part of your workflow business logic - you can catch the
    ‘ActivityFailure’ exceptions once all activity retry attempts have been exhausted (according to your retry logic for that activity) and invoke it again passing in new inputs.

  2. In your activity code you can get the current execution attempt number via:

ActivityExecutionContext context = Activity.getExecutionContext();

Based on this number you could use a different set of data for example within your activity code.
I would prefer 1. as that is cleanly defined as part of your workflow business logic.

Hope this helps.

Another option is to reset workflow before the activity invocation point. Assuming that the code provides the new arguments the activity will be rescheduled with the new arguments.