You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Anas Mosaad <an...@incorta.com> on 2016/03/08 21:59:30 UTC

What is the best way to ensure connectivity to Kafka without polling any messages

Hi All,

I am new to Kafka, I want to make sure Kafka server is available before I
can do any polling to the messages. What I did is creating a consumer
without subscription and try to access the partitions metadata for a
specific topic. This trick works for the first time. If I take the brokers
down and get one up and test the connectivity, it fails.

My problem is, I am not sure if this is the right way to ensure
connectivity. I appreciate any feedback about the best way to do this on
Kafka 0.9.0.1.

Thanks!

-- 

*Best Regards/أطيب المنى,*

*Anas Mosaad*
*Incorta Inc.*
*+20-100-743-4510*

Re: What is the best way to ensure connectivity to Kafka without polling any messages

Posted by Gwen Shapira <gw...@confluent.io>.
What we normally do is consumer.poll(0). This connects to the broker,
finds the consumer group, handles partition assignment, gets the
metadata - and then doesn't stick around to actually give you any
data.

Pretty hacky, but we use this all over the place.

Gwen

On Tue, Mar 8, 2016 at 12:59 PM, Anas Mosaad <an...@incorta.com> wrote:
> Hi All,
>
> I am new to Kafka, I want to make sure Kafka server is available before I
> can do any polling to the messages. What I did is creating a consumer
> without subscription and try to access the partitions metadata for a
> specific topic. This trick works for the first time. If I take the brokers
> down and get one up and test the connectivity, it fails.
>
> My problem is, I am not sure if this is the right way to ensure
> connectivity. I appreciate any feedback about the best way to do this on
> Kafka 0.9.0.1.
>
> Thanks!
>
> --
>
> *Best Regards/أطيب المنى,*
>
> *Anas Mosaad*
> *Incorta Inc.*
> *+20-100-743-4510*