简体   繁体   English

python-kafka:消费者是否可以根据消息属性跳过消息?

[英]python-kafka: Is possible for a consumer to skip messages based on message attributes?

Given a set of messages, each with a priority attribute. 给定一组消息,每个消息都有优先级属性。 Is it possible for a consumer to skip or ignore messages whose priority attribute is not high enough? 使用者是否可以跳过或忽略优先级属性不够高的消息?

At first I deserialized messages consumed by the kafka-python consumer, checked the priority level and discarded those messages that did not meet the required priority level. 首先,我反序列化了kafka-python使用者使用的消息,检查了优先级,并丢弃了那些不符合要求的优先级的消息。

But I am concerned that if the message is large, considerable time will be wasted deserializing messages that will not be processed further. 但是,我担心如果消息很大,则会浪费大量时间反序列化将不会进一步处理的消息。 Is there not a way for this to be done upon reading from the kafka queue? 从kafka队列中读取后,没有办法做到这一点吗?

Kafka does currently not support custom metadata in this way so the only way for the consumer to filter out certain messages is to read the payload. Kafka当前不以这种方式支持自定义元数据,因此,消费者过滤掉某些消息的唯一方法是读取有效负载。 However there is an improvement proposal under discussion which would address this kind of situation and might be worth following. 但是, 正在讨论一项改进方案,该方案将解决这种情况,可能值得关注。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM