我有一个应用程序,用于从 1 个 Kafka 生产者生成的 URL 流中下载特定的 Web 内容。我创建了一个有 5 个分区的主题,有 5 个 kafka 消费者。但网页下载的超时时间为 60 秒。
当下载其中一个 URL 时,服务器会假设消息丢失并将数据重新发送给不同的消费者。
我已经尝试了中提到的所有内容
Kafka消费者配置/性能问题 https://stackoverflow.com/questions/39888281/kafka-consumer-configuration-performance-issues
and
https://github.com/spring-projects/spring-kafka/issues/202 https://github.com/spring-projects/spring-kafka/issues/202
但我每次都会遇到不同的错误。
是否可以将特定消费者与kafka中的分区绑定?
我在我的应用程序中使用 kafka-python
我错过了 Kafka-python 的文档。我们可以使用 TopicPartition 类为特定消费者分配一个分区。
http://kafka-python.readthedocs.io/en/master/ http://kafka-python.readthedocs.io/en/master/
>>> # manually assign the partition list for the consumer
>>> from kafka import TopicPartition
>>> consumer = KafkaConsumer(bootstrap_servers='localhost:1234')
>>> consumer.assign([TopicPartition('foobar', 2)])
>>> msg = next(consumer)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)