Skip to Content
Kafka权威指南
book

Kafka权威指南

by Neha Narkhede, Gwen Shapira, Todd Palino
January 2018
Beginner to intermediate
234 pages
7h 8m
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南
可靠的数据传递
97
是一个很复杂的问题,你不应该尝试自己去解决这个问题,建议尝试一下
KafkaStreams
个类库,它为聚合、连接、时间窗和其他复杂的分析提供了高级的
DSL API
7.
长时间处理
有时候处理数据需要很长时间:你可能会从发生阻塞的外部系统获取信息,或者把数据
写到外部系统,或者进行一个非常复杂的计算。要记住,暂停轮询的时间不能超过几秒
钟。即使不想获取更多的数据,也要保持轮询,这样客户端才能往
broker
发送心跳。在
这种情况下,一种常见的做法是使用一个线程池来处理数据,因为使用多个线程可以进
行并行处理,从而加快处理速度。在把数据移交给线程池去处理之后,你就可以暂停消
费者,然后保持轮询,但不获取新数据,直到工作线程处理完成。在工作线程处理完成
之后,可以让消费者继续获取新数据。因为消费者一直保持轮询,心跳会正常发送,就
不会发生再均衡。
8.
仅一次传递
有些应用程序不仅仅需要“至少一次”(
at-least-once
)语义(意味着没有数据丢失),还
需要“仅一次”(
exactly-once
)语义。尽管
Kafka
现在还不能完全支持仅一次语义,消费
者还是有一些办法可以保证
Kafka
里的每个消息只被写到外部系统一次(但不会处理向
Kafka
写入数据时可能出现的重复数据)。
实现仅一次处理最简单且最常用的办法是把结果写到一个支持唯一键的系统里,比如键值
存储引擎、关系型数据库、
ElasticSearch
或其他数据存储引擎。在这种情况下,要么消息
本身包含一个唯一键(通常都是这样),要么使用主题、分区和偏移量的组合来创建唯一 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron
精通特征工程

精通特征工程

Alice Zheng, Amanda Casari
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115473271