0

I am implementing a message passing framework using the publish-subscribe pattern. One optimization I would like to use is maintaining only a single list of messages per topic queue, where each subscriber has a position in the list signifying their position in the message queue. Once an event has been delivered to all subscribers it gets removed from the list. I am using the publish-subscribe framework to maintain an event sourcing pattern; the messages contain the changed attributes of the underlying state.

However, I am running in to a problem when a new subscriber needs to get it's initial state, or otherwise needs a snapshot of the underlying state. I would like to insert the snapshot into the message stream to guarantee that it gets processed in the correct order in relation to the state change messages, however if done naively all subscribers will get the snapshot every time any of the subscribers request one.

At its core, the problem is that the messages are identical for all subscribers, except for the small number of snapshots. I am wondering if there is a known pattern to solve the situation, or if should solve this ad hoc?

Constantin Galbenu
  • 16,951
  • 3
  • 38
  • 54
00prometheus
  • 767
  • 7
  • 20

0 Answers0