169 lines
4.5 KiB
YAML
169 lines
4.5 KiB
YAML
# Spring Cloud Stream RocketMQ 完整配置示例
|
||
# 适用于 Spring Boot 3.x + Spring Cloud 2023.x
|
||
|
||
spring:
|
||
application:
|
||
name: erp-service
|
||
|
||
# Cloud Stream配置
|
||
cloud:
|
||
stream:
|
||
# RocketMQ Binder配置
|
||
rocketmq:
|
||
binder:
|
||
# NameServer地址(集群用分号分隔)
|
||
namesrv-addr: ${ROCKETMQ_NAMESRV_ADDR:localhost:9876}
|
||
# 开启消息追踪
|
||
enable-msg-trace: true
|
||
# 接入点配置
|
||
access-key: rocketmq
|
||
secret-key: rocketmq123
|
||
# 默认生产者配置
|
||
producer:
|
||
# 开启消息追踪
|
||
enable-msg-trace: true
|
||
# 发送超时时间(毫秒)
|
||
send-timeout: 3000
|
||
# 最大消息大小
|
||
max-message-size: 6291456
|
||
# 异步发送失败重试次数
|
||
retry-async-failure-when-send-async: 2
|
||
# 自定义追踪Topic
|
||
customized-trace-topic: RMQ_SYS_TRACE_TOPIC
|
||
|
||
# 绑定器定义
|
||
binders:
|
||
rocketmq:
|
||
type: rocketmq
|
||
default-candidate: true
|
||
environment:
|
||
spring.cloud.stream.rocketmq.binder.namesrv-addr: ${ROCKETMQ_NAMESRV_ADDR:localhost:9876}
|
||
|
||
# 函数式绑定配置(Spring Cloud Stream 4.0+ 推荐)
|
||
function:
|
||
definition: orderConsumer;inventoryConsumer;financeConsumer
|
||
|
||
# 绑定器绑定配置
|
||
bindings:
|
||
# 订单输入通道
|
||
orderConsumer-in-0:
|
||
destination: order-topic
|
||
content-type: application/json
|
||
group: erp-order-consumer-group
|
||
consumer:
|
||
concurrency: 16
|
||
maxAttempts: 3
|
||
backOffInitialInterval: 1000
|
||
backOffMaxInterval: 10000
|
||
backOffMultiplier: 2.0
|
||
binder: rocketmq
|
||
|
||
# 库存输入通道
|
||
inventoryConsumer-in-0:
|
||
destination: inventory-topic
|
||
content-type: application/json
|
||
group: erp-inventory-consumer-group
|
||
consumer:
|
||
concurrency: 16
|
||
maxAttempts: 3
|
||
binder: rocketmq
|
||
|
||
# 财务输入通道
|
||
financeConsumer-in-0:
|
||
destination: finance-topic
|
||
content-type: application/json
|
||
group: erp-finance-consumer-group
|
||
consumer:
|
||
concurrency: 12
|
||
maxAttempts: 3
|
||
binder: rocketmq
|
||
|
||
# 订单输出通道
|
||
orderProducer-out-0:
|
||
destination: order-topic
|
||
content-type: application/json
|
||
producer:
|
||
roundRobinRobin: false
|
||
partitionCount: 8
|
||
binder: rocketmq
|
||
|
||
# 库存输出通道
|
||
inventoryProducer-out-0:
|
||
destination: inventory-topic
|
||
content-type: application/json
|
||
producer:
|
||
roundRobinRobin: false
|
||
partitionCount: 8
|
||
binder: rocketmq
|
||
|
||
# 财务输出通道
|
||
financeProducer-out-0:
|
||
destination: finance-topic
|
||
content-type: application/json
|
||
producer:
|
||
roundRobinRobin: false
|
||
partitionCount: 8
|
||
binder: rocketmq
|
||
|
||
# 通知输出通道
|
||
notificationProducer-out-0:
|
||
destination: notification-topic
|
||
content-type: application/json
|
||
binder: rocketmq
|
||
|
||
# RocketMQ 客户端配置
|
||
rocketmq:
|
||
namesrv-addr: ${ROCKETMQ_NAMESRV_ADDR:localhost:9876}
|
||
producer:
|
||
group: ${spring.application.name}-producer-group
|
||
retry-times-when-send-failed: 3
|
||
timeout: 3000
|
||
max-message-size: 6291456
|
||
consumer:
|
||
group: ${spring.application.name}-consumer-group
|
||
consume-concurrency: 16
|
||
max-retry-times: 3
|
||
|
||
# ERP系统配置
|
||
erp:
|
||
rocketmq:
|
||
topics:
|
||
order: order-topic
|
||
inventory: inventory-topic
|
||
finance: finance-topic
|
||
notification: notification-topic
|
||
payment: payment-topic
|
||
consumer:
|
||
groups:
|
||
order-group: erp-order-consumer-group
|
||
inventory-group: erp-inventory-consumer-group
|
||
finance-group: erp-finance-consumer-group
|
||
notification-group: erp-notification-consumer-group
|
||
payment-group: erp-payment-consumer-group
|
||
|
||
# 服务端口
|
||
server:
|
||
port: ${PORT:8080}
|
||
|
||
# Actuator配置(用于健康检查)
|
||
management:
|
||
endpoints:
|
||
web:
|
||
exposure:
|
||
include: health,info,metrics,prometheus
|
||
endpoint:
|
||
health:
|
||
show-details: always
|
||
metrics:
|
||
export:
|
||
prometheus:
|
||
enabled: true
|
||
|
||
# 日志配置
|
||
logging:
|
||
level:
|
||
root: INFO
|
||
org.apache.rocketmq: INFO
|
||
com.erp.mq: DEBUG
|
||
org.springframework.cloud.stream: DEBUG
|