Producer API



 *  V: type of the message
 *  K: type of the optional key associated with the message
class kafka.javaapi.producer.Producer<K,V> {
  public Producer(ProducerConfig config);

   * Sends the data to a single topic, partitioned by key, using either the
   * synchronous or the asynchronous producer
   * @param message the producer data object that encapsulates the topic, key and message data
  public void send(KeyedMessage<K,V> message);

   * Use this API to send data to multiple topics
   * @param messages list of producer data objects that encapsulate the topic, key and message data
  public void send(List<KeyedMessage<K,V>> messages);

   * Close API to close the producer pool connections to all Kafka brokers.
  public void close();

发表于: 4年前   最后更新时间: 2年前   游览量:4162
上一条: kafka生产者实例
下一条: kafka使用SASL验证