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

Spring Boot配置RabbitMQ并发消费不生效问题求助

Spring Boot配置RabbitMQ并发消费不生效问题求助

各位好!最近我在优化RabbitMQ队列的消息消费效率,想着通过配置并发消费和预取数来提升处理能力,但折腾了半天发现Spring里的配置根本没生效,实在搞不定来求助大家了🥲

先说说我用的技术栈:

  • Spring Boot 3.2.5
  • Spring Cloud 2023.0.1
  • 用到了spring-cloud-stream和spring-cloud-stream-binder-rabbit
  • Java 21
  • RabbitMQ服务是3.6.12版本

这是我application.yml里的相关配置:

spring:
  application:
    name: app-third
  rabbitmq:
    host: ${RABBITMQ_URL:localhost}
    port: ${RABBITMQ_PORT:5672}
    virtual-host: ${RABBITMQ_VIRTUALHOST:}
    username: ${RABBITMQ_USER:guest}
    password: ${RABBITMQ_PASS:guest}
    listener:
      simple:
        retry:
          enabled: true
          max-attempts: 3
        concurrency: 5
        max-concurrency: 25
        prefetch: 10
  cloud:
    function:
      definition: process
    stream:
      bindings:
        process-in-0:
          destination: app.third-request
          group: app-third
        process-out-0:
  # 后面还有其他配置就不贴全了

我本来以为在spring.rabbitmq.listener.simple下面配置concurrency、max-concurrency和prefetch这些参数,就能让SimpleMessageListenerContainer开启并发消费,结果实际运行下来消息还是单线程在处理,完全没达到预期的效果。

有没有大佬能帮我排查下问题出在哪?是不是我用了spring-cloud-stream的缘故,这些配置的层级不对或者有其他特殊配置要求?

备注:内容来源于stack exchange,提问作者DJViking

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.16 11:18:13