kafka文檔(10)----0.10.1-Document-文檔(2)-APIS


2. APIS

Kafka includes four core apis:
  1. The Producer API allows applications to send streams of data to topics in the Kafka cluster.
  2. The Consumer API allows applications to read streams of data from topics in the Kafka cluster.
  3. The Streams API allows transforming streams of data from input topics to output topics.
  4. The Connect API allows implementing connectors that continually pull from some source system or application into Kafka or push from Kafka into some sink system or application.
Kafka exposes all its functionality over a language independent protocol which has clients available in many programming languages. However only the Java clients are maintained as part of the main Kafka project, the others are available as independent open source projects. A list of non-Java clients is available here.

kafka包含四種核心apis:

  1.Producer API支持向kafka集羣的topic發送數據流

  2.Consumer API支持從kafka集羣的topic獲取數據流

  3.Streams API支持從輸入topics導入數據到輸出topics

  4.Connect API支持實現從源系統或者應用程序拉取數據並導入數據到kafka的連接器或者將數據從kafka導出到其它系統或者應用


kafka提供語言無關的協議,這樣就可以使用多種語言根據協議實現kafka客戶端。然而目前官方只維護了Java客戶端,其它語言的客戶端都是一些獨立的開源項目。非java版本的客戶端列表查看這裏


2.1 Producer API

The Producer API allows applications to send streams of data to topics in the Kafka cluster.

Examples showing how to use the producer are given in the javadocs.

To use the producer, you can use the following maven dependency:

		<dependency>
			<groupId>org.apache.kafka</groupId>
			<artifactId>kafka-clients</artifactId>
			<version>0.10.1.0</version>
		</dependency>
	
2.1 Producer API

Producer API支持向kafka 集羣的topics發送數據流。

例如,這裏的javadocs展現瞭如何使用producer。

想要使用producer,你可以按照下面所示使用maven格式的配置文件:

                <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
</dependency>


2.2 Consumer API

The Consumer API allows applications to read streams of data from topics in the Kafka cluster.

Examples showing how to use the consumer are given in the javadocs.

To use the consumer, you can use the following maven dependency:

		<dependency>
			<groupId>org.apache.kafka</groupId>
			<artifactId>kafka-clients</artifactId>
			<version>0.10.1.0</version>
		</dependency>
	
2.2 Consumer API

Consumer API支持從kafka集羣中的topics讀取數據流。

例如這裏的javadocs展現瞭如何使用consumer。

想要使用consumer,你可以像下面一樣使用maven配置文件

                <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
</dependency>


2.3 Streams API

The Streams API allows transforming streams of data from input topics to output topics.

Examples showing how to use this library are given in the javadocs

Additional documentation on using the Streams API is available here.

To use Kafka Streams you can use the following maven dependency:

		<dependency>
			<groupId>org.apache.kafka</groupId>
			<artifactId>kafka-streams</artifactId>
			<version>0.10.1.0</version>
		</dependency>
2.3 Streams API

Streams API支持從輸入topics導數據到輸出topics。

這裏的javadocs可以展示如何使用這個庫的。

其它有關Streams API的文檔可以查看這裏

可以通過以下maven配置實用Kafka Streams:

               <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>0.10.1.0</version>
</dependency>


2.4 Connect API

The Connect API allows implementing connectors that continually pull from some source data system into Kafka or push from Kafka into some sink data system.

Many users of Connect won't need to use this API directly, though, they can use pre-built connectors without needing to write any code. Additional information on using Connect is availablehere.

Those who want to implement custom connectors can see the javadoc.

2.5 Legacy APIs

A more limited legacy producer and consumer api is also included in Kafka. These old Scala APIs are deprecated and only still available for compatibility purposes. Information on them can be found here here.


2.4 Connect API

Connect API實現了從源數據系統導入數據到kafka或者從kafka導入其它數據系統的連接器。

很多Connect的用戶不需要直接使用這個API,而是,可以使用已經編譯完成的Connectors,這樣就不用寫任何代碼了。

更過參考可以查看這個javadoc


2.5 其它APIs

Kafka還包含了其它一些producer以及consumer的api。原有scala apis已經廢棄了,除非是考慮到某些兼容情況,否則不建議使用了。更多信息查看這裏












發佈了130 篇原創文章 · 獲贊 40 · 訪問量 82萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章