Let's say I have a system to which I can upload documents via an API. There are three services:
UploadService- responsible for providing a HTTP endpoint
StorageService- responsible for storing uploaded documents
FileCabinet- responsible for managing a file cabinet (e.g. categories, hierarchy, etc.)
I'm trying to learn more about event-driven architecture, and now I am trying to come up with one.
UploadService can receive a command
UploadCommand and emits a
DocumentUploaded event once it created a
unique identifier for the uploaded document.
StorageService listens for the
DocumentUploaded event. Once it receives such an event, it creates a
command and handles it. The outcome is a
FileCabinet listens also for
DocumentUploaded. Once it receives such an event, it updates its state to include
the uploaded document. The outcome is a
What I don't get is, that when I would try to replay the events of the system, I would get duplicate events, since the services themselves trigger events. Am I missing some concepts here?