如何为 spring kafka 流中的多个绑定设置 UncaughtExceptionHandlers?

How to set up UncaughtExceptionHandlers for multiple bindings in spring kafka streams?

现在,我正在尝试通过以下方式访问底层的 kafka 流句柄 - https://cloud.spring.io/spring-cloud-static/Finchley.SR2/multi/multi__apache_kafka_streams_binder.html#_accessing_the_underlying_kafkastreams_object 想知道是否有更惯用的方法来做到这一点。特别是当有多个绑定时。

您可以调用 context.getBeansOfType(StreamsBuilderFactoryBean.class, false, false) 获取 beanName:factoryBean 的地图。

但是,您应该注意不要在上下文生命周期的早期执行此操作,因为这可能会导致 bean 过早实例化。

可能最好在 SmartInitializingSingleton 内进行。