Interface MessageProducer<K,V>
-
- Type Parameters:
K
- key class to sendV
- value class to send
- All Known Implementing Classes:
KafkaMessageProducer
public interface MessageProducer<K,V>
A Kafka client that publishes records to the Kafka cluster for a specific topic.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
flush()
This method is a blank default implementation in order to avoid it being a breaking change.default java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata>
send(K key, V value)
Asynchronously send a record to a specific topic.default java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata>
send(K key, V value, org.apache.kafka.clients.producer.Callback callback)
Asynchronously send a record to a specific topic and invoke the provided callback when the sending has been acknowledged.default java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata>
send(K key, V value, org.apache.kafka.common.header.Headers headers)
Asynchronously send a record to a specific topic.java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata>
send(K key, V value, org.apache.kafka.common.header.Headers headers, org.apache.kafka.clients.producer.Callback callback)
Asynchronously send a record to a specific topic and invoke the provided callback when the sending has been acknowledged.
-
-
-
Method Detail
-
send
default java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata> send(K key, V value)
Asynchronously send a record to a specific topic.- Parameters:
key
- key to sendvalue
- value to send- Returns:
- The result of sending is a
RecordMetadata
specifying the partition the record was sent to, the offset it was assigned and the timestamp of the record. Noop implementations may returnnull
instead of aFuture
.
-
send
default java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata> send(K key, V value, org.apache.kafka.common.header.Headers headers)
Asynchronously send a record to a specific topic.- Parameters:
key
- key to sendvalue
- value to sendheaders
- headers to include in the message- Returns:
- The result of sending is a
RecordMetadata
specifying the partition the record was sent to, the offset it was assigned and the timestamp of the record. Noop implementations may returnnull
instead of aFuture
.
-
send
default java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata> send(K key, V value, org.apache.kafka.clients.producer.Callback callback)
Asynchronously send a record to a specific topic and invoke the provided callback when the sending has been acknowledged. The sending is asynchronous and this method will return immediately once the record has been stored in the buffer of records waiting to be sent.- Parameters:
key
- key to sendvalue
- value to sendcallback
- callback to invoke- Returns:
- The result of sending is a
RecordMetadata
specifying the partition the record was sent to, the offset it was assigned and the timestamp of the record. Noop implementations may returnnull
instead of aFuture
.
-
send
java.util.concurrent.Future<org.apache.kafka.clients.producer.RecordMetadata> send(K key, V value, org.apache.kafka.common.header.Headers headers, org.apache.kafka.clients.producer.Callback callback)
Asynchronously send a record to a specific topic and invoke the provided callback when the sending has been acknowledged. The sending is asynchronous and this method will return immediately once the record has been stored in the buffer of records waiting to be sent.- Parameters:
key
- key to sendvalue
- value to sendheaders
- headers to include in the messagecallback
- callback to invoke- Returns:
- The result of sending is a
RecordMetadata
specifying the partition the record was sent to, the offset it was assigned and the timestamp of the record. Noop implementations may returnnull
instead of aFuture
.
-
flush
default void flush()
This method is a blank default implementation in order to avoid it being a breaking change. The implementing class must override this to add behaviour to it. The implementation should call the flush() method of the producer.
-
-