org.apache.kafka.clients.producer
Interface Producer<K,V>

All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
KafkaProducer, MockProducer

public interface Producer<K,V>
extends java.io.Closeable

The interface for the KafkaProducer

See Also:
KafkaProducer, MockProducer

Method Summary
 void close()
          Close this producer
 java.util.Map<MetricName,? extends Metric> metrics()
          Return a map of metrics maintained by the producer
 java.util.List<PartitionInfo> partitionsFor(java.lang.String topic)
          Get a list of partitions for the given topic for custom partition assignment.
 java.util.concurrent.Future<RecordMetadata> send(ProducerRecord<K,V> record)
          Send the given record asynchronously and return a future which will eventually contain the response information.
 java.util.concurrent.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
 

Method Detail

send

java.util.concurrent.Future<RecordMetadata> send(ProducerRecord<K,V> record)
Send the given record asynchronously and return a future which will eventually contain the response information.

Parameters:
record - The record to send
Returns:
A future which will eventually contain the response information

send

java.util.concurrent.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


partitionsFor

java.util.List<PartitionInfo> partitionsFor(java.lang.String topic)
Get a list of partitions for the given topic for custom partition assignment. The partition metadata will change over time so this list should not be cached.


metrics

java.util.Map<MetricName,? extends Metric> metrics()
Return a map of metrics maintained by the producer


close

void close()
Close this producer

Specified by:
close in interface java.io.Closeable