I am trying to use a high level consumer for batch to read messages. During reading this batch, my thread must stop at some point.
Either when all messages end in the subject or get the maximum offset at that point when reading and stopping the messages, until the maximum offset is reached.
I tried to use the code but the KafkaStream seems to be a blocked call and waits until another message arrives.
So 3 questions,
-
How do I know that there is no other message than the subject has read?
-
If there is an answer to the question given above, how can I stop listening to this topic now?
-
What is the way to find the maximum offset when the batch reads start (I think simple consumers can do this) and at that time the high level consumer has to stop?
You have the option to decide when a specified message No new messages have been sent to you, so all messages have been read. This consumer property can be set using consumer.timeout.ms
. After being passed without any new messages coming without this specified value, the consumer user will throw an exception at the same time and you can get more out of that user.
No comments:
Post a Comment