You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by anand jain <an...@gmail.com> on 2014/08/05 07:21:01 UTC

Consumer is never shutdown

Hi,

I just started with Apache Kafka and wrote a high level consumer program
following the example given here
https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example.

Though, I was able to run the program and consume the messages, I have one
doubt regarding *consumer.shutdown()*. It has never been called. I used the
below piece of code to verify
 if (consumer != null) {
    System.out.println("shutting down consumer");
    consumer.shutdown();
}

Has someone encountered this before? Also, even if consumer didn't
shutdown, I didn't notice any bottleneck. Is it really needed?

Regards
Anand

Re: Consumer is never shutdown

Posted by Sharninder <sh...@gmail.com>.
Without looking at your complete code, I'm only going to make some guesses.

Unless you really want to shutdown the consumer, why would you call
consumer.shutdown()? A consumer will keep waiting for new messages unless
otherwise specified.

I'm guessing you used something like while iterator.hasNext() to get
messages from the queue. This will not return unless you explicitly call
shutdown which means you will have to write a condition which calls
shutdown based on the message contents.

--
Sharninder



On Tue, Aug 5, 2014 at 10:51 AM, anand jain <an...@gmail.com> wrote:

> Hi,
>
> I just started with Apache Kafka and wrote a high level consumer program
> following the example given here
> https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example.
>
> Though, I was able to run the program and consume the messages, I have one
> doubt regarding *consumer.shutdown()*. It has never been called. I used the
> below piece of code to verify
>  if (consumer != null) {
>     System.out.println("shutting down consumer");
>     consumer.shutdown();
> }
>
> Has someone encountered this before? Also, even if consumer didn't
> shutdown, I didn't notice any bottleneck. Is it really needed?
>
> Regards
> Anand
>