Kafka Consumer hanging at .hasNext in java

后端 未结 2 831
粉色の甜心
粉色の甜心 2021-01-04 21:20

I have a simple Kafka Consumer in java with the following code

    public void run() {
        ConsumerIterator it = m_stream.iterator(         


        
相关标签:
2条回答
  • 2021-01-04 21:54

    The method hasNext() is blocking.

    you can change the timeout of the blocking in the propertyconsumer.timeout.ms

    Note that it will throw a TimeoutException when the timeout will expire.

    Would read these docs about the consumers: https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example

    0 讨论(0)
  • 2021-01-04 21:57

    The solution was to add the property

    "consumer.timeout.ms"

    Now when the timeout is reached a ConsumerTimeoutException is thrown

    0 讨论(0)
提交回复
热议问题