[英]KafkaJS consume from multiple topics with one consumer
I want to implement retry
logic while consuming from Kafka topic
using KafkaJS , so basically, I will have 2 topics main-topic
and retry-topic
and I will我想在使用KafkaJS从Kafka topic
消费时实现retry
逻辑,所以基本上,我将有 2 个主题main-topic
和retry-topic
我会
read from -> main-topic
阅读 -> main-topic
if processing fails |如果处理失败 | -> retry topic
-> retry topic
so is it a bad practice to use one consumer
for listening from both topics(both main
and retry
), as kafka
allows to listen from multiple topics using same consumer.因此,使用一个consumer
收听两个主题(包括main
和retry
)是一种不好的做法,因为kafka
允许使用同一消费者收听多个主题。
It's not a bad practice at all.这根本不是一个坏习惯。
The only problem you may run into using one consumer is that the topics may need differ configurations (connection settings, deserializer, etc).使用一个消费者可能遇到的唯一问题是主题可能需要不同的配置(连接设置、反序列化器等)。 In that case, you can create two separate Consumer instances rather than one subscribing to both.在这种情况下,您可以创建两个单独的 Consumer 实例,而不是一个订阅两者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.