It is said that in CQRS it is easy to fix a bug, you just redeploy and then replay the events.But, what if one of the events should cause an external system not in your control to ship an item to the customer if you just replay the events the item would be shipped twice.How do you resolve that?
How to handle side effects in CRQS when replaying events?
distributed computing;cqrs;event sourcing
You need to make a clear separation between events modifying the state of your read model, and events (potentially) modifying the state of external systems. Make sure you do not have any mixed events modifying both states together. That way, you can replay your events in a specific replay mode where those events for the external system are not fired again. In this mode, you also simulate any events which had been originally been initiated by the external system (now you take them from the replay queue instead).Don't forget, the redeploy step means actually to reset the state of the read model to an earlier point in time. This is probably nothing you can do (or need to do) for the state of the external systems.