Replay a Workflow multiple times not working

I am using resetWorkflowExecution api present in java-sdk to replay a workflow.
I have observed a few things while replaying same workflow multiple times:

  1. When I replay currently running workflow, history of same runId gets resetted to given historyEventId and it executes workflow. Next time when I try to replay the same, it doesn’t reset the history and doesn’t throw any error also and gives back the same runId.

  2. When I replay a failed workflow, a new runId gets created and I get that as response from api. If workflow fails again and I replay it again, it does not creates a new runId, doesn’t throw any error and gives back the same runId that was returned before.

Is it any known issue?? Or is it possible to reset a workflow multiple times or not? Do I need to set any property in WorkflowOptions or something for making it possible to replay multiple times?

make sure to change the request ID

Thanks !
I was not using Request Id before. Using a unique requestId solved the issue.

Can you also provide some scenarios in replay for

  1. when will existing workflow be replayed keeping runId intact
  2. when will existing workflow be terminated and new workflow with new runId will be created.

first of all, replay vs reset are totally different thing.

replay usually means the following scenario: one of your workflow worker goes offline, another workflow worker picks up the workflow history & reconstruct the workflow state and move on. in this case, run ID is not changed.

reset means you want to reuse a prefix section of a workflow (either running or closed, see a), the prefix section will be “copy & pasted” (see b) into a new workflow (new run ID)
a. if the workflow to be reused is running, this workflow will be terminated
b. Temporal server will not actually copy & paste workflow history, but reuse it.