clj-kafka.new.producer
Clojure interface to the “new” Kafka Producer API. For complete JavaDocs, see: http://kafka.apache.org/082/javadoc/org/apache/kafka/clients/producer/package-summary.html
producer
(producer config)
(producer config key-serializer value-serializer)
Return a KafkaProducer
for publishing records to Kafka. KafkaProducer
instances are thread-safe and should generally be shared for best performance.
Implements Closeable
, so suitable for use with with-open
.
For available config options, see: http://kafka.apache.org/documentation.html#newproducerconfigs
record
(record topic value)
(record topic key value)
(record topic partition key value)
Return a record that can be published to Kafka using send.
send
(send producer record)
(send producer record callback)
Asynchronously send a record to Kafka. Returns a Future
of a map with :topic
, :partition
and :offset
keys. Optionally provide a callback fn that will be called when the operation completes. Callback should be a fn of two arguments, a map as above, and an exception. Exception will be nil if operation succeeded.
For details on behaviour, see http://kafka.apache.org/082/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html#send(org.apache.kafka.clients.producer.ProducerRecord,org.apache.kafka.clients.producer.Callback)