That’s a very good point — yes, events coming from different partitions can be processed out of order. If you do need events to be globally ordered, than you need to implement a custom Partitioner that will put them in the same partition.

Typically the partitioning is by aggregate root id (an aggregate root can contain multiple entities in its tree), but of course everything depends on the specific use-case.

In general, when dealing with multiple aggregate roots, you have to be prepared for temporal inconsistencies — that’s why these systems are eventually consistent :). That isn’t Kafka-specific — you’ll see that property in all stream-based event-sourcing systems, or even NoSQL databases without transactions.

Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store