I don't think call allDone will cause hasNext() to exit. The new consumer has a 
timed poll() function on it's API I think.
With the old consumer, interrupting the thread calling hasNext might work. Have 
you tried that?

Aditya

________________________________________
From: Gomathivinayagam Muthuvinayagam [sankarm...@gmail.com]
Sent: Monday, May 11, 2015 6:26 PM
To: users@kafka.apache.org
Subject: Kafka listener threads - graceful shutdown

I am using the following code to help kafka stream listener threads to exit
out of the blocking call of hasNext() on the consumerIterator. But the
threads never exit, when they receive allDone() signal. I am not sure
whether I am making any mistake. Please let me know is this right approach.


    public void stop() throws InterruptedException {

        for (ConsumerIterator<byte[], byte[]> consumer : consumerIterators)
{

            consumer.allDone();

        }

        shutdown();

    }
Thanks & Regards,

Reply via email to