Both the @SignalMethod and the @UpdateMethod update the state of the workflow, the @SignalMethod was conveniently used with the signalWithStart() method allowing me to start a workflow if it’s not started already, and signal it if it’s already running.
I have seen a few instances where the @UpdateMethod can race with the @SignalMethod and cause disruptions in the event histories, affecting the replays of events when the workflow state gets reconstructed on long running workflows.
Temporal SDK: 1.25.0
Code Snippet:
@WorkflowInterface
public interface DemoWorkflow {
@WorkflowMethod
void startWorkflow(WorkflowInput input);
@UpdateMethod
Response get(String Id);
@SignalMethod
void aggregate(Payload payload);
}
// client code:
final BatchRequest batchRequest = workflowClient.newSignalWithStartRequest();
batchRequest.add(notificationWorkflow::startWorkflow, new WorkflowInput());
batchRequest.add(workflow::aggregate, payload);
final WorkflowExecution workflowExecution = workflowClient.signalWithStart(batchRequest);