【个人技术经验及开发技巧分享】 【个人技术经验及开发技巧分享】
首页
  • 操作系统初识
  • JAVA基础
  • JVM
  • 开发框架
  • Redis
  • Zookeeper
  • 消息中间件
  • 持久化
  • 算法
  • 网络
  • 系统架构
  • 并发编程
  • 框架
  • 开发杂货
  • 线上排查
  • 技巧备忘
  • 部署指南
  • 版本管理
  • 工作流程
  • 发版流程
  • 友情链接
  • 网站备忘
  • 在线工具
  • 学习
  • 各种云
  • 应用下载

Louis

首页
  • 操作系统初识
  • JAVA基础
  • JVM
  • 开发框架
  • Redis
  • Zookeeper
  • 消息中间件
  • 持久化
  • 算法
  • 网络
  • 系统架构
  • 并发编程
  • 框架
  • 开发杂货
  • 线上排查
  • 技巧备忘
  • 部署指南
  • 版本管理
  • 工作流程
  • 发版流程
  • 友情链接
  • 网站备忘
  • 在线工具
  • 学习
  • 各种云
  • 应用下载
  • 开发杂货

    • ES查询压测
    • Spring Cloud Stream
    • 线上Tomcat配置参考
    • 配置Prometheus及健康检测
    • Feign支持BasicAuth验证
    • Feign远程调用
    • Hystrix单方法熔断配置
    • 邮件发送自定义Excel
    • 本地开发联调配置
    • RabbitMQ配置备忘
      • 1 配置示例
      • 2 延时队列
    • Nacos配置中心
    • Java代码杂记
    • Oracle脚本备忘
    • Mysql并发数与连接数
    • 批量算费本地工具类
    • Apollo配置模糊查询
    • 异步任务AsyncIAE
    • 生产环境机器配置参考
  • 线上排查

  • 技巧备忘

  • 部署指南

  • 技术应用
  • 开发杂货
luoxiaofeng
2022-05-29
目录

RabbitMQ配置备忘

# 1 配置示例

添加死信及延时队列时,需删除旧有交换机和队列

spring:
  cloud:
    stream:
      bindings:
        cainiao-big-bag-data-input:
          destination: cainiao-big-bag-data
          binder: mq-crs
          group: crs-cainiao
          consumer:
            maxAttempts: 3
            backOffInitialInterval: 10000
            backOffMaxInterval: 200000
            backOffMultiplier: 3.0
          # 回传配载预报信息更新队列  
        test-callback-stowage_forecast-output:
          destination: test-callback-stowage_forecast
          binder: mq-crs
        test-callback-stowage_forecast-input:
          destination: test-callback-stowage_forecast
          binder: mq-crs
          group: test-callbackstowageForecast
          # 回传承运重量信息队列
        test-weight-output:
          destination: test-weight
          binder: mq-crs
        test-weight-input:
          destination: test-weight
          binder: mq-crs
          group: test-callbackWeight

      rabbit:
        bindings:
          cainiao-big-bag-data-input:
            consumer:
              concurrency: 4
              max-concurrency: 8
              prefetch: 10
              auto-bind-dlq: true
              republish-to-dlq: true
          test-callback-stowage_forecast-input:
            consumer:
              concurrency: 4
              max-concurrency: 8
              prefetch: 10
              auto-bind-dlq: true
              republish-to-dlq: true
          test-weight-output:
            producer:
              delayedExchange: true
          test-weight-input:
            consumer:
              delayedExchange: true
              concurrency: 4
              max-concurrency: 8
              prefetch: 10
              auto-bind-dlq: true
              republish-to-dlq: true
      defaultBinder: mq-crs
      binders:
        mq-crs:
          type: rabbit
          environment:
            spring:
              rabbitmq:
                addresses: xxxx.xx.xx.xxx:5672
                username: admin
                password: 123456
                virtual-host: /yl-crs-cn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

# 2 延时队列

发送端

@Component
public interface TestOutputSource {

  String TIKTOK_WEIGHT_OUTPUT = "test-weight-output";

  @Output(TIKTOK_WEIGHT_OUTPUT)
  MessageChannel testWeightOutput();

}
1
2
3
4
5
6
7
8
9
@Service
@Slf4j
@EnableBinding(value = {TestOutputSource.class})
public class YlCrsCallbackFlightInfoServiceImpl implements IYlCrsCallbackFlightInfoService {

  @Resource
  private TestOutputSource testOutputSource;

  public void sendMes() {
    //正常发送
    TransportInfoDTO transportInfoDTO = buildTransportInfoDTO(bigBagConfirmDTO);
    testOutputSource.transportDataOutput().send(MessageBuilder.withPayload(transportInfoDTO).build());

    //延迟10分钟发送
    TestWeightDTO testWeightDTO = buildTestWeightDTO(bigBagConfirmDTO);
    Message message = MessageBuilder.withPayload(testWeightDTO).setHeader("x-delay", 600000).build();
    testOutputSource.testWeightOutput().send(message);
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

消费端

public interface TestInputSource {
  
  String TIKTOK_WEIGHT_INPUT = "test-weight-input";

  @Input(TIKTOK_WEIGHT_INPUT)
  MessageChannel testWeightInput();
  
}
1
2
3
4
5
6
7
8
@Slf4j
@EnableBinding(TestInputSource.class)
public class CallbackTestListener {

  @StreamListener(value = TestInputSource.TIKTOK_WEIGHT_INPUT)
  public void callbackWight(@Payload Message<TestWeightDTO> message) {

    TestWeightDTO request = message.getPayload();

  }
}
1
2
3
4
5
6
7
8
9
10
11
本地开发联调配置
Nacos配置中心

← 本地开发联调配置 Nacos配置中心→

最近更新
01
SpringBoot
10-21
02
Spring
10-20
03
Sentinel
10-14
更多文章>
Copyright © 2022-2023 Louis | 粤ICP备2022060093号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式