Context: invoicing system, the sent invoices must have consecutive numbers.
Each invoice has a unique invoice number, for sake of simplicity let's say they are I1, I2, I3, and so on. So, the first invoice in the system has the number I1, and it gets incremented for every next invoice. Then, each invoice is being produced in a Kafka topic.
So, one could always calculate the number for the next invoice only by the contents of this topic, right? (count of invoices in the topic + 1 = next number) We could call such a system event-sourced then.
But how do you achieve this? For me, this seems like a circular data flow: in order to produce into the topic, I first need to ensure that I consumed the same whole topic at another place.
Am I getting something wrong about event streaming or is it just impossible with Kafka?
Invoices are always being assigned the number and sent one-by-one, not in parallel.