Reputation: 41240
I am just experimenting on Kafka as a SSE holder on the server side and I want "replay capability". Say each kafka topic is in the form events.<username>
and it would have a delete items older than X time set.
Now what I want is an API that looks like
GET /events/offset=n
offset
would be the last processed offset by the client if not specified it is the same as latest
offset + 1 which means no new results. It can be earliest
which represents the earliest possible entry. The offset
needs to exist as a security-through-obscurity check.
My suspicion is for this to work correctly the topic must remain in ONE partition and cannot scale horizontally. Though because the topics are tied to a user name the distribution between brokers would be handled by the fact that the topics are different.
Upvotes: 0
Views: 47
Reputation: 16824
If you want to retain event sequence for each of the per-user topics, then yes, you have to use one partition per user only. Kafka cannot guarantee message delivery order with multiple partitions.
The earliest
and latest
options you mention are already supported in any basic Kafka consumer configuration. The specific offset one, you'd have to filter out manually by issuing a request for the given offset, and then returning nothing if the first message you receive does not match the requested offset.
Upvotes: 1