public interface Producer<K,V> extends Closeable
KafkaProducer
KafkaProducer
,
MockProducer
Modifier and Type | Method and Description |
---|---|
void |
abortTransaction()
|
void |
beginTransaction()
|
void |
close()
Close this producer
|
void |
close(long timeout,
TimeUnit unit)
Tries to close the producer cleanly within the specified timeout.
|
void |
commitTransaction()
|
void |
flush()
Flush any accumulated records from the producer.
|
void |
initTransactions()
|
Map<MetricName,? extends Metric> |
metrics()
Return a map of metrics maintained by the producer
|
List<PartitionInfo> |
partitionsFor(String topic)
Get a list of partitions for the given topic for custom partition assignment.
|
Future<RecordMetadata> |
send(ProducerRecord<K,V> record)
Send the given record asynchronously and return a future which will eventually contain the response information.
|
Future<RecordMetadata> |
send(ProducerRecord<K,V> record,
Callback callback)
Send a record and invoke the given callback when the record has been acknowledged by the server
|
void |
sendOffsetsToTransaction(Map<TopicPartition,OffsetAndMetadata> offsets,
String consumerGroupId)
|
void initTransactions()
void beginTransaction() throws ProducerFencedException
ProducerFencedException
void sendOffsetsToTransaction(Map<TopicPartition,OffsetAndMetadata> offsets, String consumerGroupId) throws ProducerFencedException
ProducerFencedException
void commitTransaction() throws ProducerFencedException
ProducerFencedException
void abortTransaction() throws ProducerFencedException
ProducerFencedException
Future<RecordMetadata> send(ProducerRecord<K,V> record)
record
- The record to sendFuture<RecordMetadata> send(ProducerRecord<K,V> record, Callback callback)
void flush()
List<PartitionInfo> partitionsFor(String topic)
Map<MetricName,? extends Metric> metrics()
void close()
close
in interface AutoCloseable
close
in interface Closeable
void close(long timeout, TimeUnit unit)