这个问题严格来说是肯定有的,kafka只能保证分区内的有序性。
下面是kafka作者Jay Kreps的blog中介绍kafka设计思想的一段话。
Each partition is a totally ordered log, but there is no global ordering between partitions (other than perhaps some wall-clock time you might include in your messages). The assignment of the messages to a particular partition is controllable by the writer, with most users choosing to partition by some kind of key (e.g. user id). Partitioning allows log appends to occur without co-ordination between shards and allows the throughput of the system to scale linearly with the Kafka cluster size.
针对部分消息有序(message.key相同的message要保证消费顺序)场景,可以在producer往kafka插入数据时控制,同一key分发到同一partition上面。
kafka源码如下,支持该方式
private
[kafka]
class
DefaultPartitioner[T]
extends
Partitioner[T] {
private

本文探讨了在Kafka中如何保证部分消息的消费顺序性,特别是针对message.key相同的消息。Kafka仅能确保分区内的消息顺序,而通过控制Producer将同一key的消息发送至同一分区,可以实现部分有序。在Kafka-Storm集成测试中,由于模拟数据的随机性导致了负数滞留时间的计算错误。解决方案包括业务层面的规避和处理失败的重试策略优化。此外,文章还提到了Kafka消费原理的相关知识。
最低0.47元/天 解锁文章
185

被折叠的 条评论
为什么被折叠?



