kafka文档(10)----0.10.1-Document-文档(2)-APIS
2. APISKafka includes four core apis:The Producer API allows applications to send streams of data to topics in the Kafka cluster.The Consumer API allows applications to read streams of data from
2. APIS
- The Producer API allows applications to send streams of data to topics in the Kafka cluster.
- The Consumer API allows applications to read streams of data from topics in the Kafka cluster.
- The Streams API allows transforming streams of data from input topics to output topics.
- 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包含四种核心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已经废弃了,除非是考虑到某些兼容情况,否则不建议使用了。更多信息查看这里。
更多推荐
所有评论(0)