简单接入消息队列

mymx2
mymx2 2019-09-06 11:15
阅读需:0

参考春哥的https://gitee.com/596392912/mica 可以自定义输入输出

yaml配置:

spring:
  cloud:
    stream:
      rabbit:
        bindings:
          service-error-out:
            producer:
              routing-key-expression: '''error-out''' #定义 RoutingKey 的表达式配置
          service-error-in:
            consumer: # 进行消费端配置
              bindingRoutingKey: error-out # 设置一个RoutingKey信息
      binders: # 在此处配置要绑定的rabbitmq的服务信息;
        defaultRabbit: # 表示定义的名称,用于于binding整合
          type: rabbit # 消息组件类型
          environment: #配置rabbimq连接环境
            spring:
              rabbitmq:
                host: xxx.xxx.xxx.xxx
                username: root
                password: rabbitmqadmin
                virtual-host: /
      bindings: # 服务的整合处理
        service-error-out:    #生产者绑定,这个是消息通道的名称
          binder: defaultRabbit  # 设置要绑定的消息服务的具体设置
          destination: exchange-msgSender  #exchange名称,交换模式默认是topic;把SpringCloud stream的消息输出通道绑定到RabbitMQ的xchange-msgSender交换器。
          content-type: application/json   #设置消息类型,本次为对象json,如果是文本则设置“text/plain”
        service-error-in:
          binder: defaultRabbit
          destination: exchange-msgSender
          content-type: application/json
        service-time-out:
          binder: defaultRabbit
          destination: exchange-msgTimeout
          content-type: application/json


评论
  • 消灭零回复