Spring Boot + RabbitMQ 配置参数解释

最近生产 RabbitMQ 出了几次问题,所以抽时间整理了一份关于 Spring Boot 整合 RabbitMQ 环境下的配置参数解释,通过官网文档和网上其他朋友一些文章参考归纳整理而得,有错误之处还请指正 ~

★RabbitMQ
★Version: 1.5.13.RELEASE

★属性文件:org.springframework.boot.autoconfigure.amqp.RabbitProperties

★Config:
# base
spring.rabbitmq.host: 服务 Host
spring.rabbitmq.port: 服务端口
spring.rabbitmq.username: 登陆用户名
spring.rabbitmq.password: 登陆密码
spring.rabbitmq.virtual-host: 连接到 rabbitMQ 的 vhost
spring.rabbitmq.addresses: 指定 client 连接到的 server 的地址,多个以逗号分隔 (优先取 addresses,然后再取 host)
spring.rabbitmq.requested-heartbeat: 指定心跳超时,单位秒,0 为不指定;默认 60s
spring.rabbitmq.publisher-confirms: 是否启用【发布确认】
spring.rabbitmq.publisher-returns: 是否启用【发布返回】
spring.rabbitmq.connection-timeout: 连接超时,单位毫秒,0 表示无穷大,不超时
spring.rabbitmq.parsed-addresses:


# ssl
spring.rabbitmq.ssl.enabled: 是否支持 ssl
spring.rabbitmq.ssl.key-store: 指定持有 SSL certificate 的 key store 的路径
spring.rabbitmq.ssl.key-store-password: 指定访问 key store 的密码
spring.rabbitmq.ssl.trust-store: 指定持有 SSL certificates 的 Trust store
spring.rabbitmq.ssl.trust-store-password: 指定访问 trust store 的密码
spring.rabbitmq.ssl.algorithm: ssl 使用的算法,例如,TLSv1.1


# cache
spring.rabbitmq.cache.channel.size: 缓存中保持的 channel 数量
spring.rabbitmq.cache.channel.checkout-timeout: 当缓存数量被设置时,从缓存中获取一个 channel 的超时时间,单位毫秒;如果为 0,则总是创建一个新 channel
spring.rabbitmq.cache.connection.size: 缓存的连接数,只有是 CONNECTION 模式时生效
spring.rabbitmq.cache.connection.mode: 连接工厂缓存模式:CHANNEL 和 CONNECTION


# listener
spring.rabbitmq.listener.simple.auto-startup: 是否启动时自动启动容器
spring.rabbitmq.listener.simple.acknowledge-mode: 表示消息确认方式,其有三种配置方式,分别是 none、manual 和 auto;默认 auto
spring.rabbitmq.listener.simple.concurrency: 最小的消费者数量
spring.rabbitmq.listener.simple.max-concurrency: 最大的消费者数量
spring.rabbitmq.listener.simple.prefetch: 指定一个请求能处理多少个消息,如果有事务的话,必须大于等于 transaction 数量.
spring.rabbitmq.listener.simple.transaction-size: 指定一个事务处理的消息数量,最好是小于等于 prefetch 的数量.
spring.rabbitmq.listener.simple.default-requeue-rejected: 决定被拒绝的消息是否重新入队;默认是 true(与参数 acknowledge-mode 有关系)
spring.rabbitmq.listener.simple.idle-event-interval: 多少长时间发布空闲容器时间,单位毫秒

spring.rabbitmq.listener.simple.retry.enabled: 监听重试是否可用
spring.rabbitmq.listener.simple.retry.max-attempts: 最大重试次数
spring.rabbitmq.listener.simple.retry.initial-interval: 第一次和第二次尝试发布或传递消息之间的间隔
spring.rabbitmq.listener.simple.retry.multiplier: 应用于上一重试间隔的乘数
spring.rabbitmq.listener.simple.retry.max-interval: 最大重试时间间隔
spring.rabbitmq.listener.simple.retry.stateless: 重试是有状态 or 无状态


# template
spring.rabbitmq.template.mandatory: 启用强制信息;默认 false
spring.rabbitmq.template.receive-timeout: receive() 操作的超时时间
spring.rabbitmq.template.reply-timeout: sendAndReceive() 操作的超时时间
spring.rabbitmq.template.retry.enabled: 发送重试是否可用
spring.rabbitmq.template.retry.max-attempts: 最大重试次数
spring.rabbitmq.template.retry.initial-interval: 第一次和第二次尝试发布或传递消息之间的间隔
spring.rabbitmq.template.retry.multiplier: 应用于上一重试间隔的乘数
spring.rabbitmq.template.retry.max-interval: 最大重试时间间隔

 

参考文档:

Spring Cloud 中 RabbitMQ 配置属性表:  https://blog.csdn.net/en_joker/article/details/80103519

SpringBoot 的 RabbitMQ 消息队列: 第二模式 "Work queues"  https://blog.csdn.net/lxhjh/article/details/69054342

SpringBoot 官方文档:https://docs.spring.io/spring-amqp/docs/1.5.6.RELEASE/reference/html/_reference.html

SpringBoot 系统 - 死信队列: https://www.cnblogs.com/bigdataZJ/p/springboot-deadletter-queue.html