Gülsen Keskin
Gülsen Keskin

Reputation: 810

Consume only a specific number of messages from the queue

Is it possible to consume only a specific number of messages like 10 or 50 or 100 messages from the 1000 that are in the queue? I was looking at 'fetch.max.bytes' config, but it seems like it is for a message size rather than number of messages.

I don't know how to set "max.partition.fetch.bytes" as my byte size is not the same in every message.

Is there a way to dynamically set this to read 10 or 50 or 100 messages per minute?

Or is there any way I can do this?

note : please "max.poll.records" note that I cannot use the method

Upvotes: 0

Views: 968

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191854

Per minute? No, not really, because you have little control as a consumer client over producer speeds or even network speeds.

If you just want a static number, seek the consumer to a specific partition offset and simply count the number of records consumed until you're satisfied with the number, then commit the offsets back (or don't).

Upvotes: 1

Related Questions