Ordering of Pinned Strategy

Follow up to this question to Pinned Persistent Subscription: order of events within one bucket

The answer mentions ordering of events when there is a single subscriber.
Incase there are multiple subscribers to the persistent subscription(pinned strategy), will I receive the messages in order on each of those subscribers, for a given streamID?

The answer would be the same. It’s the best effort to guarantee a delivery order to a specific subscriber. EventStoreDB will try to keep the order and deliver it as was selected, but it’s the best effort approach. If you need to have a 100% ordering guarantee, then you’d have to use regular subscriptions, define the sharding, checkpointing, retry strategy tuned to your use case.

You can read more in general about this case in my article “How to scale projections in the event-driven systems?”. Check also more about “Competing Consumers”

1 Like

The times things will get out of order are on retries, and on changes to the number of subscribers.

Even when doing a completely custom approach getting duplicate delivery and exact ordering is very difficult to get provably correct without significant locking and/or other convolutions.

However, as it seems that you are looking for a consumer to process by stream, this can all be made very simple for either the built in or a custom approach. :grin:

You can leverage the incrementing Event Position in the stream as a checkpoint for idempotency, missing message detection, and out of order detection.

Give the consumer the capacity to request missing messages and an idempotency check based on the highest position processed and all of you ordering problems are sorted.

1 Like