Two suggestions:

1. While the consumer is connected, it has one or more threads called
"ConsumerFetcherThread-<consumer ID>-<fetcherID>-<brokerID>"
If you can look at which threads are currently running and check if any
called ConsumerFetcherThread-* exist, this is a good indication.
The threads are closed when shutdown() is called.

2. ConsumerConnector logs at INFO level when shutdown starts and completes.
You can add a Log4J appender that will update the file you need.

Hope this helps.

Gwen


On Sun, Aug 30, 2015 at 12:16 AM, yoel g <yoel...@gmail.com> wrote:

> Hey,
> I want to create a monitor in my code which sample the Kafka connection and
> updates a file according to connection status (connected\disconnected).
> Unfortunately, I couldn't find any field in the "ConsumerConnector" class
> or any other class which indicates what is the status of the connection.
> (for example: how can I determine if the process called
> ConsumerConnector.shutdown() ?)
> Basically I need only to know if we are connected to Kafka or not.
> If you have an easy way for implementing such thing I'll appreciate it.
> I'm using JAVA with the 0.8.1.1 kafka version library
>
> Thanks!!
>

Reply via email to