3

I’m wondering if there is an easy way in ReBus to be notified when all “child” events (all events with a specific correlation id) have been executed.

ilcorvo
  • 446
  • 5
  • 18

1 Answers1

3

I am not entirely sure what you are trying to achieve, but if I understand you correctly you are simply asking how to know when a couple of particular messages have been processed.

In many cases, this can be solved by implementing logic similar to this in each subscriber:

public class SomeSubscriberHandler : IHandleMessages<AnEvent>
{
    public async Task Handle(AnEvent anEvent)
    {
        // handle event by doing something
        // ...

        // let the world know I did something
        await _bus.Publish(new SomeSubscriberDidSomething(anEvent.CorrelationId));
    }      
}

thereby allowing a saga to subscribe to SomeSubscriberDidSomething, correlating by the enclosed CorrelationId.

If all subscribers do this, the saga can easily determine how far this process has come, and then figure out some final thing to do when all subscribers have done their things.

mookid8000
  • 18,258
  • 2
  • 39
  • 63