Current state: Draft
Discussion thread: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
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.
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)
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?
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.