繁体   English   中英

卡夫卡消费者阅读某些主题但不是其他主题

[英]Kafka Consumer reading from some topics but not others

我有一个 Kafka Streams 应用程序,它从一组主题中读取,用一些额外的数据丰富消息,然后输出到另一组主题,例如:

topic.blue.unprocessed -> Kafka Streams App -> topic.blue.processed

topic.yellow.unprocessed -> Kafka Streams App -> topic.yellow.processed

消费者组使用正则表达式主题模式设置,并将读取带有前缀主题的topic.

这在一段时间内工作得很好,但我最近注意到它已经停止阅读来自某些主题的消息,例如。 没有来自topic.yellow.unprocessed的消息被读取,但topic.blue.unprocessed仍然运行良好。

我调查了日志,可以看到该应用程序仍在一个月前从topic.yellow.unprocessed读取,但是从消息出现在主题上到 Streams 应用程序读取它之间存在 5 天的很大延迟。 现在它根本不阅读它们。

想知道是否有人知道为什么这可能只发生在某些主题上 - 我希望如果应用程序或消费者 ACL 存在问题,它会影响所有主题,但我没有看到这种情况发生。

我已经确认topic.yellow.unprocessed已部署并正在接收消息 - 它们只是没有被应用程序使用。 调试日志已启用,但未显示任何内容。

请参阅下面的消费者代码:

    @Value("${kafka.configuration.inputTopicRegex}")
    private String inputTopicRegex;

    @Value("${kafka.configuration.deadLetterTopic}")
    private String deadLetterTopic;

    @Value("${kafka.configuration.brokerAddress}")
    private String brokerAddress;

    @Autowired
    AvroRecodingSerde avroSerde;

    public KafkaStreams createStreams() {
        return new KafkaStreams(createTopology(), createKakfaProperties());

    }

    private Properties createKakfaProperties() {
        Properties config = new Properties();
        config.put(StreamsConfig.APPLICATION_ID_CONFIG, "topic.color.app");
        config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, brokerAddress);
        config.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
        config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
        config.put(StreamsConfig.DEFAULT_DESERIALIZATION_EXCEPTION_HANDLER_CLASS_CONFIG, LogAndContinueExceptionHandler.class.getName());
        config.put(StreamsConfig.PROCESSING_GUARANTEE_CONFIG, StreamsConfig.EXACTLY_ONCE);
        config.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 86400000);
        return config;
    }

    public Topology createTopology() {
        StreamsBuilder builder = new StreamsBuilder();

        // stream of records
        KStream<String, GenericRecord> ingressStream = builder.stream(Pattern.compile(inputTopicRegex), Consumed.with(Serdes.String(), avroSerde));

        KStream<String, GenericRecord> processedStream = ingressStream.transformValues(enrichMessage);

        processedStream.to(destinationOrDeadletter, Produced.with(Serdes.String(), avroSerde));

        return builder.build();
    }

暂无
暂无

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

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