Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Kafka >> mail # user >> producer.send atomic?

Kane Kane 2013-10-16, 15:57
Copy link to this message
Re: producer.send atomic?
Hi Kane,

If the producer is async, the send(requests) function call would not
necessarily trigger the real sending action. The sending action is
triggered either if enough time has elapsed or enough messages have been
batched on the client side. One batch of messages to each broker will be
either send successfully or not at all (in this sense "atomic"), and if
failed the whole batch will be re-tried to that broker again.

As for consumers (I am assuming high-level consumers here), since the
consumers themselves will need to remember the offsets still which they
have consumed, if the consume request fails the consumers will just
re-issue the request starting with the previous offsets again.

On Wed, Oct 16, 2013 at 8:56 AM, Kane Kane <[EMAIL PROTECTED]> wrote:

> Hello, as I understand send is not atomic, i.e. i have something like this
> in my code:
>     val requests = new ArrayBuffer[KeyedMessage[AnyRef, AnyRef]]
>     for (message <- messages) {
>       requests += new KeyedMessage(topic, null, message, message)
>     }
>     producer.send(requests)
> That means batch can die in the middle?
> Also what happens if during this write the broker that has some partition
> leaders will die? The same question for consumer, what happens if broker
> dies while consumer reading from it?
> Thanks.

-- Guozhang

Kane Kane 2013-10-16, 17:52
Guozhang Wang 2013-10-16, 18:08