This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • KIP-420: Return CompletableFuture from KafkaProducer.send
Skip to end of metadata
Go to start of metadata

Status

Current stateDraft

Discussion thread: here

JIRA: here

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Producer and KafkaProducer return a java.util.concurrent.Future from their send methods. This makes it challenging to write asynchronous non-blocking code given Future's limited interface. Since Kafka now requires Java 8, we now have the option of using CompletionStage and/or CompletableFuture that were introduced to solve this issue. It's worth noting that the Kafka AdminClient solved this issue by using org.apache.kafka.common.KafkaFuture as Java 7 support was still required then.

Public Interfaces

Change the send methods of org.apache.kafka.clients.producer.KafkaProducer to return java.util.concurrent.CompletableFuture instead of java.util.concurrent.Future:

public CompletableFuture<RecordMetadata> send(ProducerRecord<K, V> record)
public CompletableFuture<RecordMetadata> send(ProducerRecord<K, V> record, Callback callback)

Proposed Changes

Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.

Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users?
  • If we are changing behavior how will we phase out the older behavior?
  • If we need special migration tools, describe them here.
  • When will we remove the existing behavior?

Rejected Alternatives

If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.

  • No labels