Producer API

半兽人 发表于: 2015-02-07   最后更新时间: 2016-10-25  
  •   1 订阅,3382 游览

kafka生产API

kafka生产者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();
}






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

评论…


  • 评论…
    • in this conversation
      提问