I am using play framework and Apache Kafka.
I have a POST method which sends a message to Kafka. Kafka has an API method
public java.util.concurrent.Future send(ProducerRecord record, Callback callback)
of which the Javadoc says
Asynchronously send a record to a topic and invoke the provided callback when the send has been acknowledged.
I am exposing this functionality using the play framework. I want to return a Promise<Result>
from the Controller method but can't figure out how to implement this in a non-blocking way. Can someone help me with this?
After some searching found the answer with some help from this one.
Following is the code