You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Pulsar监听器无法接收消息:原因排查与解决方案

Spring Pulsar监听器无法接收消息问题排查与解决

环境配置

  • Spring Boot 3.0.1
  • Spring Pulsar Starter依赖:org.springframework.pulsar:spring-pulsar-spring-boot-starter:0.1.1-SNAPSHOT
  • 运行环境:arm64架构Mac,使用x86版本JDK 19.0.2-amzn(因conscrypt暂不支持arm64)

问题表现

  • 消息发送功能正常,但@PulsarListener注解的监听器完全无法接收消息
  • 开启org.apache.pulsar的Debug日志后,出现三类异常提示:
    • 类找不到:org.apache.pulsar.shade.org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport
    • 本地库加载失败:无法加载netty_tcnative系列库
    • 方法链接错误:调用org.apache.pulsar.shade.io.netty.internal.tcnative.Library.aprMajorVersion()时出错
  • 尝试在pom.xml中手动添加netty-tcnative依赖,问题未得到解决

最终解决方案

问题核心并非日志中显示的依赖或本地库问题,而是带有@PulsarListener注解的类未被Spring容器扫描识别为Bean。只需给该监听器类添加@Service(或@Component、@Repository等Spring Bean注解),确保Spring容器能发现并管理该类,添加后监听器即可正常接收消息。

内容的提问来源于stack exchange,提问作者Marcus Hellberg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 20:05:31