# RocketMQ Spring Cloud Stream Configuration
# 所有微服务共享的基础配置

rocketmq:
  # NameServer地址
  namesrv-addr: ${ROCKETMQ_NAMESRV_ADDR:localhost:9876}
  
  # 客户端配置
  client:
    # 客户端类型：JAVA | CPP | .NET | Python | Go | NodeJS
    type: JAVA
    
    # 客户端日志级别
    log:
      level: INFO
    
    # 线程池配置
    threadpool:
      # 生产者线程池大小
      producer:
        core-size: 10
        max-size: 50
        queue-size: 10000
      
      # 消费者线程池大小  
      consumer:
        core-size: 20
        max-size: 100
        queue-size: 10000

  # 生产者配置
  producer:
    # 发送失败重试次数
    retry-times-when-send-failed: 3
    # 异步发送失败重试次数
    retry-times-when-send-async-failed: 2
    # 最大消息大小
    max-message-size: 6291456
    # 压缩阈值
    compress-msg-body-over-howmuch: 4096
    # 发送超时时间（毫秒）
    timeout: 3000

  # 消费者配置
  consumer:
    # 消费模式：CLUSTERING | BROADCASTING
    mode: CLUSTERING
    # 消息拉取策略
    pull-batch-size: 32
    # 消费并发度
    consume-concurrency: 16
    # 最大重试次数
    max-retry-times: 16
    # 重试间隔（毫秒）
    retry-interval: 1000

  # 高可用配置
  ha:
    # 主从同步时间间隔
    ha-sync-timestamp-interval: 1000
    # 主从同步检测间隔
    ha-heartbeat-interval: 1000

# Spring Cloud Stream RocketMQ Binder
spring:
  cloud:
    stream:
      rocketmq:
        # Binder配置
        binder:
          # NameServer地址
          namesrv-addr: ${ROCKETMQ_NAMESRV_ADDR:localhost:9876}
          # 生产者配置
          producer:
            # 开启消息追踪
            enable-msg-trace: true
            # 接入点名称
            access-key: rocketmq
            secret-key: rocketmq123
        # 默认绑定器配置
        default-binder: rocketmq

# ERP系统消息主题配置
erp:
  rocketmq:
    topics:
      order: order-topic
      inventory: inventory-topic
      finance: finance-topic
      notification: notification-topic
      payment: payment-topic
      warehouse: warehouse-topic
      customer: customer-topic
      report: report-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
        warehouse-group: erp-warehouse-consumer-group
        customer-group: erp-customer-consumer-group
        report-group: erp-report-consumer-group
