NServiceBus saga one-time running

Hello,

We are implementing saga that is responsible for performing complex operation that should run only once. This operation is triggered by event. This events can be raised multiple times by the system. Idea is to create saga with state that will define if saga is started and exit if is so. Use IFindSagas for choose correct saga. This saga won`t be completed.

Is there any restrictions for using saga that won`t be completed?
In case we would like to manually restart this saga - should we just delete row from from sagas table and create new request?

Thanks

There is no real issue with leaving saga instances around other than the data requirements (i.e. keeping the row in the database). You can accomplish this with a simple boolean flag in the saga data. Something like this:

public async Task Handle(TriggeringEvent message, IHandleMessageContext context)
{
  if(!Data.OperationStarted)
  {
    Data.OperationStarted = true;
    await context.Send(
      new StartComplexOperation { BusinessId = message.BusinessId }
    ).ConfigureAwait(false);
  }
}

public async Task Handle(ResetOperationFlag message, IHandleMessageContext context)
{
  Data.OperationStarted = false;
}

How often is the event fired?

@alexpol did my answer help to get you unstuck? Is there any other information that I can provide?