Hi Neha,

For the "connection at creation time", I had the issue with the sync producer 
only, didn't observe this with the async producer, I didn't test it yet, but I 
guess I would get similar issues.

I didn't keep the stacktrace as it happened some time ago, but basically, 
calling "new Producer()" resulted in an exception, because the connection to ZK 
wasn't working, I'm using "zk.connect".

In the setup I was testing, I have a zk cluster spanning on 2 sites, in the 
second site, zk is in "observer" mode only. From time to time, the observer 
loses its sync with the leader and for a short period of time you can see these 
"zookeeper server not running" in the log (during sync with leader). If the 
producer is created (application started) at that time, it will fail. Again, I 
assume the same would happen if ZK wasn't running at all.

The solution I had so far was to wrap the producer to handle this, and try to 
create it again when ZK is coming up.

As I understand, once created, the producer / consumer would reconnect 
automatically, it would be nice to extend this behavior and support to be in a 
disconnected state at startup.
    
Kindly,

Nicolas Berthet

-----Original Message-----
From: Neha Narkhede [mailto:neha.narkh...@gmail.com] 
Sent: Tuesday, April 30, 2013 10:53 PM
To: users@kafka.apache.org
Subject: Re: Producer / Consumer - connection management

> Basically, who and how is managing network disconnection / outage ?

Short answer is that the producer is responsible for retrying connection 
establishment and it automatically does so when the network connection to the 
broker fails. There is a connection retry interval that you can use.
Once that is reached it gives up trying to reconnect.

> 1 ) If the "sync" producer has been created successfully, will it
reconnect whenever it loses its connection to the broker or zk ? I could 
understand it's not happening as we expect the connection to be immediately 
available when using the sync producer.

The ZK client library manages connection loss and reconnects to ZK. But be 
aware that ZK not being unavailable is never an option.

> 2 ) How about the "async" producer ? Does it expect connection at
creation time ? will it reconnect in case of failure ?

Can you describe what connection issue you see at creation time. Is it just 
when you use the zk.connect option ?

> 3 ) Finally, how about the "high level" consumer ? Afaik, it 
> reconnects
automatically

It does, so does producer.

Reply via email to