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 <[email protected]> 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
