I have 2 CQRS+ES Event Driven System (EDS), they both share the same EventStore and my EventStore also streams its data being like an EventBus. Currently both EDS subscribes to the same EventBus but are listening to different events.
When EDS2 publishes an OrderCreatedEvent, I need EDS1 to pick that event and perform some of its own domain logic. I believe this should be done by sending its own domain Command.
Sample Implementation of the OrderCreatedEvent handler in EDS1:
public class OrderCreatedEventHandler: INotificationHandler<OrderCreatedEvent>
{
public Task Handle(OrderCreatedEvent orderEvent, CancellationToken cancellationToken)
{
await _mediator.Send(new SendShippingNotificationCommand(order.Id));
await _mediator.Send(new SendOrderEmailCommand(order.Id));
}
}
With the above implementation and architecture design, how am i able to replay events in EDS1? assuming i need to replay to compute projection. Because each time i replay the events, the OrderCreatedEvent handler will be called and sends out the 2 commands again. Is there any suggestions to overcome this?