当前位置:网站首页>Delay queue optimization (2)
Delay queue optimization (2)
2022-07-30 18:33:00 【a breezy】
A new queue QC is added here, the binding relationship is as follows, the queue does not set TTL time

Configuration class file:
@Bean("queueC")public Queue queueC(){HashMap args = new HashMap();args.put("x-dead-letter-exchange",Y_DEAD_LETTER_EXCHANGE);args.put("x-dead-letter-routing-key","YD");// No TTL property declared herereturn QueueBuilder.durable(QUEUE_C).withArguments(args).build();}@Beanpublic Binding queueBindingX(@Qualifier("queueC") Queue queueC,@Qualifier("xExchange") DirectExchange exchange){return BindingBuilder.bind(queueC).to(exchange).with("XC");} Producer:
@[email protected]("ttl")@RestControllerpublic class Produce01 {@Autowiredprivate RabbitTemplate rabbitTemplate;// @GetMapping("sendMsg/{message}")// public void sendMsg(@PathVariable String message)// {//// log.info("Current time: {}, send a message to two TTL queues: {}", new Date(), message);// rabbitTemplate.convertAndSend("X","XA","message from 10s"+message);// rabbitTemplate.convertAndSend("X","XB","The message comes from 40s"+message);// }@GetMapping("sendExpirationMsg/{message}/{ttlTime}")public void senMsg(@PathVariable String message,@PathVariable String ttlTime){log.info("Current time: {}, send a TTL message with duration {} milliseconds to queue C:{}", new Date(), ttlTime, message);rabbitTemplate.convertAndSend("X","XC",message, correlationData ->{correlationData.getMessageProperties().setExpiration(ttlTime);return correlationData;});}}Consumer:
@[email protected] class Consumer {@RabbitListener(queues = "QD")public void receiveD(Message message, Channel channel){String s = new String(message.getBody());log.info("Current time{}, message received by dead letter queue D---->{}",new Date(),s);}}
p>
It doesn't seem to be a problem, but at the beginning, it was introduced that if you use the method of setting TTL on the message property, the message may not "die" on time, because RabbitMQ will only check the firstWhether the message is expired, if it expires, it will be thrown into the dead letter queue,
If the first message has a long delay and the second message has a short delay, the second message will not be executed first.
边栏推荐
- Network Basics (3) 01-Basic Concepts of Networks - Protocols, Host Addresses, Paths and Parameters of URL Addresses & 127.0.0.1 Local Loopback Address & View URL IP Address and Access Ping Space + URL
- 怎么样的框架对于开发者是友好的?
- After 23 years of operation, the former "China's largest e-commerce website" has turned yellow...
- Common linked list problems and their Go implementation
- 《自然语言处理实战入门》---- 文本样本扩展小技巧:使用回译技术进行样本增强
- 【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
- ESP8266-Arduino programming example-BMP180 air pressure temperature sensor driver
- LeetCode 练习——关于查找数组元素之和的两道题
- Redis for infrastructure
- 中集世联达工业级成熟航运港口人工智能AI产品规模化应用,打造新一代高效能智慧港口和创新数字港口,全球港航人工智能能领军者中集飞瞳
猜你喜欢

经济新闻:错误# 15:初始化libiomp5md。dll,但发现libiomp5md。已经初始化dll。解决方法

线性筛求积性函数

Scrapy框架介绍

WeChat Mini Program Cloud Development | Urban Information Management

时序数据库在船舶风险管理领域的应用

ByteArrayInputStream class source code analysis

cocos creater 热更重启导致崩溃

6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?

Quickly build an e-commerce platform based on Amazon cloud technology serverless service - performance

Mysql执行原理剖析
随机推荐
网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口
基于inquirer封装一个控制台文件选择器
时序数据库在船舶风险管理领域的应用
Deepen school-enterprise cooperation and build an "overpass" for the growth of technical and skilled talents
AWS console
mysql的多实例
Swiper轮播图片并播放背景音乐
【HMS Core】【FAQ】运动健康、音频编辑、华为帐号服务 典型问题合集7
固定资产可视化智能管理系统
ROS 节点初始化步骤、topic/service创建及使用
C# wpf 无边框窗口添加阴影效果
WeChat Mini Program Cloud Development | Urban Information Management
SwiftUI iOS 精品开源项目之 完整烘焙食品菜谱App基于SQLite(教程含源码)
【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
Web结题报告
Application of time series database in the field of ship risk management
微信小程序云开发 | 城市信息管理
"Ruffian Heng Embedded Bimonthly" Issue 59
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
Basic use of scrapy
p>