Say I have a service that is producing events of the format
type: SEND_MESSAGE, to: '[email protected]',
And I have another service, that is saying, "for the next four hours, I want to consume all
SEND_MESSAGE events that are directed to the people in this array:
["[email protected]", "[email protected]", [email protected]"]".
So ok, this consumer can just consume the queue and ignore any messages that it doesn't care about.
However, at the end of the four hours, it also wants to know 'Which people in this list didn't I get messages for, I want to do some kind of action based on that'.
How would this be achieved with an event-driven architecture?
As far as I know, there are three kinds of approaches:
- You have some kind of database/persistent store that the second service uses to keep track of which people it has received messages for.
- Either the consuming service, or another service, that creates a 'people who have been sent messages' aggregation event.
- You have an event queue that supports 'look back in time', and you just examine the last four hours of events.
On this third point - my understanding is that some event queues/streams support this, and others being necessarily ephemeral - (ie. services have to deal with the event in the moment, or miss it forever). Or is this a misunderstanding on my part?
What I'm wondering, is what are the key concepts and standard patterns used in event driven architecture I would use to solve this problem?