I am assuming that when we call continueAsNew, it restarts execution with a different runId and same workflow id and that it would reset any field values, since it’s a new run. I want to retain the values across new runs when I do continueAsNew
, How can I achieve this ? Can I continueAsNew with signal
similar to startWithSignal method which takes in a batch request ?
Example:
public class MyWorkflowImpl implements MyWorkflow {
private final MyActivity activity =
Workflow.newActivityStub(MyActivity.class, DEFAULT_ONE_ATTEMPT_ACTIVITY_OPTIONS);
private boolean isExecutionPaused = false;
@Override // @WorkflowMethod
public void start() {
activity.doSomething();
Workflow.await(Duration.ofHours(1), () -> !isExecutionPaused);
if (isExecutionPaused) {
activity.doSomethingElse();
Workflow.continueAsNew(); // I want to continueAsNew with isExecutionPaused = true
}
Workflow.continueAsNew();
}
@Override // @SignalMethod
public void signalMethod(boolean isExecutionPaused) {
this.isExecutionPaused = isExecutionPaused;
}
}
For example, in the above code, if a signal sets isExecutionPaused = true; And during continueAsNew(), I want to retain the value of isExecutionPaused which I think will reset in above case to false, on continueAsNew().
I would appreciate if someone can help me here. Thanks in advance.