You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Ewen Cheslack-Postava <ew...@confluent.io> on 2015/12/02 08:43:00 UTC

Re: flush() vs close()

Kashif,

The difference is that close() will also shut down the producer such that
it can no longer send any messages. flush(), in contrast, is useful if you
want to make sure that all the messages enqueued so far have been sent and
acked, but also want to send more messages after that.

-Ewen

On Wed, Nov 25, 2015 at 7:01 AM, Kashif Usmani <us...@gmail.com>
wrote:

> Hello,
>
>
> I notice that 0.9 Kafka release had a new flush() call added to the
> producer API (See https://issues.apache.org/jira/browse/KAFKA-1865).
>
> I am trying to understand what is the difference between producer.flush()
> and producer.close()? They seem to be doing pretty similar work. If not,
> can someone please explain?
>
> KAFKA-1865 mentions that flush() would ensure “that any record enqueued
> prior to flush() would have completed being sent (either successfully or
> not).” and javadocs for close() say that “Close this producer. This
> method blocks until al in-flight requests complete.” Does ‘in-flight
> requests complete’ mean same as enqueued records are sent to Kafka?
>
>
>
> Kashif
>



-- 
Thanks,
Ewen

Re: flush() vs close()

Posted by Muqtafi Akhmad <mu...@traveloka.com>.
hello Ewen,

so the flush() operation is already included in close() ? how about
implementation before 0.9.0 version?

Thank you,

On Wed, Dec 2, 2015 at 2:43 PM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> Kashif,
>
> The difference is that close() will also shut down the producer such that
> it can no longer send any messages. flush(), in contrast, is useful if you
> want to make sure that all the messages enqueued so far have been sent and
> acked, but also want to send more messages after that.
>
> -Ewen
>
> On Wed, Nov 25, 2015 at 7:01 AM, Kashif Usmani <
> usmani.kashif9957@gmail.com>
> wrote:
>
> > Hello,
> >
> >
> > I notice that 0.9 Kafka release had a new flush() call added to the
> > producer API (See https://issues.apache.org/jira/browse/KAFKA-1865).
> >
> > I am trying to understand what is the difference between producer.flush()
> > and producer.close()? They seem to be doing pretty similar work. If not,
> > can someone please explain?
> >
> > KAFKA-1865 mentions that flush() would ensure “that any record enqueued
> > prior to flush() would have completed being sent (either successfully or
> > not).” and javadocs for close() say that “Close this producer. This
> > method blocks until al in-flight requests complete.” Does ‘in-flight
> > requests complete’ mean same as enqueued records are sent to Kafka?
> >
> >
> >
> > Kashif
> >
>
>
>
> --
> Thanks,
> Ewen
>



-- 
Muqtafi Akhmad
Software Engineer
Traveloka