Producer API

半兽人 发表于: 2015-02-07   最后更新时间: 2016-10-25 22:24:12  
{{totalSubscript}} 订阅, 6,880 游览

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();
}
更新于 2016-10-25
在线,1小时前登录

查看history更多相关的文章或提一个关于history的问题,也可以与我们一起分享文章