WCID
V2EX  ›  Java

Spring Kafka 疑惑:默认情况下, endpoint registry 的 destroy 方法有啥卵用吗

  •  
  •   WCID · Feb 17, 2020 · 3183 views
    This topic created in 2454 days ago, the information mentioned may be changed or developed.

    KafkaListenerEndpointRegistry.destroy():

    public void destroy() {
        for (MessageListenerContainer listenerContainer : getListenerContainers()) {
            if (listenerContainer instanceof DisposableBean) {
                try {
                    ((DisposableBean) listenerContainer).destroy();
                } catch (Exception ex) {
                    this.logger.warn("Failed to destroy message listener container", ex);
                }
            }
        }
    }
    

    貌似 SpringKafka 中实现了 MessageListenerContainer 接口的类都没有实现 DisposableBean 接口

    3 replies  •  2020-02-25 22:14:45 +08:00
    WCID
    WCID
    OP
    Feb 17, 2020
    1
    大佬们能不能解一下惑,是我哪里看漏了吗
    hantsy
    hantsy
    Feb 24, 2020
    2
    不明白你要表达什么东西。

    如果是你自己的或者其它第三方的 MessageListenerContainer Bean 可以实现 DisposableBean。
    WCID
    WCID
    OP
    Feb 25, 2020
    3
    @hantsy 为什么框架里的 MessageListenerContainer 自己不实现呢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1067 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:35 · PVG 02:35 · LAX 10:35 · JFK 13:35
    ♥ Do have faith in what you're doing.