Vadym
Vadym

Reputation: 11

How to zip (aggregate) multiple events into single one?

I want to subscribe to two events and publish a new one only when both of the previous ones happen. How to implement it properly? Which message broker is suitable for this case?

I'm currently researching the event aggregation pattern but can't figure out how to apply it to a microservice architecture. How should I store events until there is a match for them? In memory or in a database?

Upvotes: 1

Views: 54

Answers (1)

Cosmin Ioniță
Cosmin Ioniță

Reputation: 4055

There are 2 aspects I would consider for this particular situation:

  • What data volume is expected to be received on each queue? If you're expecting like millions of events per minute, then keeping them in memory would be the fastest option, since you don't have to go off-process to take the decisioning of sending the final event. Of course, you may end up filling up the memory very fast, so you need a cluster of machines with enough memory to store the events.
  • If you're decisioning is based on some particular traits of the event, so if you need some kind of filtering to find the events that would trigger the final event to be sent, then you may wait more time for the right event to come up, so it would make more sense to store them in an external cache (if the performance requirements allow that, of course)

Upvotes: 0

Related Questions