Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 多个自定义kafka流在初始化时提供了实例_Java_Spring Boot_Apache Kafka_Apache Kafka Streams_Spring Kafka - Fatal编程技术网

Java 多个自定义kafka流在初始化时提供了实例

Java 多个自定义kafka流在初始化时提供了实例,java,spring-boot,apache-kafka,apache-kafka-streams,spring-kafka,Java,Spring Boot,Apache Kafka,Apache Kafka Streams,Spring Kafka,我在Spring boot中使用3个不同的流构建和3个不同的KafkaStreamsConfiguration bean实现了3个具有不同源和目标主题的kafka流,并为每个流定制了应用程序id。当我启动应用程序时,我收到以下错误: [9/27/20, 15:10:52:538 GST] 000000e5 SystemOut O 2020-09-27 15:10:52.538 [RequestI

我在Spring boot中使用3个不同的流构建和3个不同的KafkaStreamsConfiguration bean实现了3个具有不同源和目标主题的kafka流,并为每个流定制了应用程序id。当我启动应用程序时,我收到以下错误:

[9/27/20, 15:10:52:538 GST] 000000e5 SystemOut                                                    O 2020-09-27 15:10:52.538 [RequestId: ] [consumer_id: ] [kafka-producer-network-thread | streams-group-87604411-8c60-4ba1-a54a-52fb48ea2bf6-StreamThread-2-0_4-producer] ERROR o.a.k.s.p.i.RecordCollectorImpl - stream-thread [events-streams-group-87604411-8c60-4ba1-a54a-52fb48ea2bf6-StreamThread-2] task [0_4] Error encountered sending record to topic consumed-events for task 0_4 due to:
org.apache.kafka.common.KafkaException: Failing batch since transaction was aborted
Exception handler choose to CONTINUE processing in spite of this error but written offsets would not be recorded.
下面是流代码

final KStream<String, JsonNode> stream = profileBuilder.stream(profileInputTopic, Consumed.with(Serdes.String(), jsonSerde));

        Properties profileProps = streamsConfig.kStreamsConfigs().asProperties();

        stream.transform(CustomTransformer::new)
                .through(consumedEventsTopic, Produced.with(Serdes.String(), jsonSerde))
                .map((key, value) -> {
                            try {
                                return Parser.parse(key, value);
                            } catch (Exception e) {
                                LOGGER.error("Error occurred - " + e.getMessage());
                            }
                            return new KeyValue<>(null, null);
                        }
                )
                .filter((key, value) -> {
                    try {
                        return MessageFilter.filterNonNull(key, value);
                    } catch (Exception e) {
                        LOGGER.error("Error occurred - " + e.getMessage());
                    }
                    return false;
                })
                .through(
                        outputTopic,
                        Produced.with(Serdes.String(), new JsonPOJOSerde<>(ElasticMessage.class)))
                .process(CustomLogProcessor::new);
final KStream stream=profileBuilder.stream(profileinputopic,consumered.with(Serdes.String(),jsonSerde));
Properties profileProps=streamsConfig.kstreamconfig().asProperties();
stream.transform(CustomTransformer::new)
.through(consumedEventsTopic,producted.with(Serdes.String(),jsonSerde))
.map((键、值)->{
试一试{
返回Parser.parse(键,值);
}捕获(例外e){
LOGGER.error(“发生错误-”+e.getMessage());
}
返回新的KeyValue(null,null);
}
)
.filter((键、值)->{
试一试{
返回MessageFilter.filterNonNull(键,值);
}捕获(例外e){
LOGGER.error(“发生错误-”+e.getMessage());
}
返回false;
})
.通过(
输出,
生成的.with(Serdes.String(),新的JsonPOJOSerde(ElasticMessage.class)))
.进程(CustomLogProcessor::新建);
这会导致流关闭。 当我将一个默认流与一个默认流生成器一起使用时,我不会得到任何异常,它都可以很好地工作,但这个问题仅在多个自定义流中出现

如何解决这个问题

另一个问题-当我在KafkaStreams配置中更新application.id(用于设置使用者组id)并重新启动应用程序时,该值没有得到更新,原因是什么


谢谢

不要抱怨Spring boot是如何工作的,但是如果单独运行一个应用程序可以工作,但多个应用程序不能工作,那么在配置方面似乎有一些“重叠”。确保每个应用程序都有自己独特的
application.id
——并在日志中进行验证。