Saga - If IAmStartedByMessages message received saga started and before closing the saga again if we received the same message with same contextid, then i have to use the existing saga for some operation.
How can we handle this.
Ex -
public class AddEmployeeSaga : Saga,
IAmStartedByMessages,
IHandleMessages
{
}
If INewEmployeeReceived first time, then saga is started and before closing the saga. If we received same INewEmployeeReceived for same employeeId, then i have to use existing saga and continue processing.
Assuming that INewEmployeeReceived is the message/event starting the Saga and the contextid is the Saga instance correlation you don’t have to do any special thing. Saga concurrency behavior ensures that only one message starts the saga. The second message will be retry because of optimistic concurrency and in the second processing attempt the previous created Saga instance will be found.