【问题标题】:How to set up UncaughtExceptionHandlers for multiple bindings in spring kafka streams?如何为spring kafka流中的多个绑定设置UncaughtExceptionHandlers?
【发布时间】:2019-05-20 19:53:49
【问题描述】:

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

【问题讨论】:

    标签: apache-kafka-streams spring-cloud-stream


    【解决方案1】:

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

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

    最好在SmartInitializingSingleton 中完成。

    【讨论】:

    • 感谢您的回复,这确实有效!似乎仍然存在潜在的竞争条件,因为 KafkaStreams 只允许在其处于 CREATED 状态时设置异常处理程序。
    猜你喜欢
    • 2021-03-15
    • 2021-09-28
    • 2020-10-29
    • 2021-07-25
    • 2021-02-07
    • 1970-01-01
    • 2020-05-17
    • 1970-01-01
    • 2018-09-25
    相关资源
    最近更新 更多