Let's say I have a system to which I can upload documents via an API. There are three services:
- the
UploadService
- responsible for providing a HTTP endpoint - the
StorageService
- responsible for storing uploaded documents - the
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.
The UploadService
can receive a command UploadCommand
and emits a DocumentUploaded
event once it created a
unique identifier for the uploaded document.
The StorageService
listens for the DocumentUploaded
event. Once it receives such an event, it creates a StoreDocument
command and handles it. The outcome is a DocumentStoredEvent
.
The FileCabinet
listens also for DocumentUploaded
. Once it receives such an event, it updates its state to include
the uploaded document. The outcome is a DocumentFiledEvent
.
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?