You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by 王有胜 <wo...@gmail.com> on 2023/11/12 09:10:09 UTC

About Kafka Java Client Producer Retry And Callback

Hi Community, I use Kafka Java Client to send messages asynchronously.
I wonder if the producer fails to send a message, during the retry
period, will the callback be executed for each retry?
I debugged the source code
org.apache.kafka.clients.producer.internals.Sender#canRetry and
org.apache.kafka.clients.producer.internals.Sender#reenqueueBatch
parts, and I'm still not sure.
Can anyone help answer this question?
In addition, is there any way to make Kafka producers retry locally? I
want to completely understand the code logic.
Thanks!

Re: About Kafka Java Client Producer Retry And Callback

Posted by 1 <li...@126.com>.
退订




On 11/14/2023 18:19,王有胜<wo...@gmail.com> wrote:
Thanks for your answer, I set a large min.insync.replicas for the
topic and I can see in the console log that Kafka Sender keeps
retrying.

Haruki Okada <oc...@gmail.com> 于2023年11月13日周一 16:50写道:

will the callback be executed for each retry

The callback will be triggered only once when the produce is finally ended
up with succeeded or failed after retries.

is there any way to make Kafka producers retry locally

Easiest way would be to make produce failing artificially. it can be done
by e.g.:
- set acks=all and set topic's min.insync.replicas to impossibly large value
- use iptables between producer and broker to block the network connectivity

2023年11月12日(日) 18:10 王有胜 <wo...@gmail.com>:

Hi Community, I use Kafka Java Client to send messages asynchronously.
I wonder if the producer fails to send a message, during the retry
period, will the callback be executed for each retry?
I debugged the source code
org.apache.kafka.clients.producer.internals.Sender#canRetry and
org.apache.kafka.clients.producer.internals.Sender#reenqueueBatch
parts, and I'm still not sure.
Can anyone help answer this question?
In addition, is there any way to make Kafka producers retry locally? I
want to completely understand the code logic.
Thanks!



--
========================
Okada Haruki
ocadaruma@gmail.com
========================

Re: About Kafka Java Client Producer Retry And Callback

Posted by 王有胜 <wo...@gmail.com>.
Thanks for your answer, I set a large min.insync.replicas for the
topic and I can see in the console log that Kafka Sender keeps
retrying.

Haruki Okada <oc...@gmail.com> 于2023年11月13日周一 16:50写道:
>
> > will the callback be executed for each retry
>
> The callback will be triggered only once when the produce is finally ended
> up with succeeded or failed after retries.
>
> > is there any way to make Kafka producers retry locally
>
> Easiest way would be to make produce failing artificially. it can be done
> by e.g.:
> - set acks=all and set topic's min.insync.replicas to impossibly large value
> - use iptables between producer and broker to block the network connectivity
>
> 2023年11月12日(日) 18:10 王有胜 <wo...@gmail.com>:
>
> > Hi Community, I use Kafka Java Client to send messages asynchronously.
> > I wonder if the producer fails to send a message, during the retry
> > period, will the callback be executed for each retry?
> > I debugged the source code
> > org.apache.kafka.clients.producer.internals.Sender#canRetry and
> > org.apache.kafka.clients.producer.internals.Sender#reenqueueBatch
> > parts, and I'm still not sure.
> > Can anyone help answer this question?
> > In addition, is there any way to make Kafka producers retry locally? I
> > want to completely understand the code logic.
> > Thanks!
> >
>
>
> --
> ========================
> Okada Haruki
> ocadaruma@gmail.com
> ========================

Re: About Kafka Java Client Producer Retry And Callback

Posted by Haruki Okada <oc...@gmail.com>.
> will the callback be executed for each retry

The callback will be triggered only once when the produce is finally ended
up with succeeded or failed after retries.

> is there any way to make Kafka producers retry locally

Easiest way would be to make produce failing artificially. it can be done
by e.g.:
- set acks=all and set topic's min.insync.replicas to impossibly large value
- use iptables between producer and broker to block the network connectivity

2023年11月12日(日) 18:10 王有胜 <wo...@gmail.com>:

> Hi Community, I use Kafka Java Client to send messages asynchronously.
> I wonder if the producer fails to send a message, during the retry
> period, will the callback be executed for each retry?
> I debugged the source code
> org.apache.kafka.clients.producer.internals.Sender#canRetry and
> org.apache.kafka.clients.producer.internals.Sender#reenqueueBatch
> parts, and I'm still not sure.
> Can anyone help answer this question?
> In addition, is there any way to make Kafka producers retry locally? I
> want to completely understand the code logic.
> Thanks!
>


-- 
========================
Okada Haruki
ocadaruma@gmail.com
========================