当前位置:网站首页>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.
边栏推荐
- 载誉而归,重磅发布!润和软件亮相2022开放原子全球开源峰会
- ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver
- 【HMS Core】【FAQ】运动健康、音频编辑、华为帐号服务 典型问题合集7
- SwiftUI iOS 精品开源项目之 完整烘焙食品菜谱App基于SQLite(教程含源码)
- 国轩高科瑞交所上市:募资近7亿美元 为瑞士今年最大融资项目
- 【Qt Designer工具的使用】
- Chapter 4 Controlling the Execution Flow
- ctf.show_web5
- Confluence OGNL注入漏洞复现(CVE-2022-26134)
- LeetCode 练习——关于查找数组元素之和的两道题
猜你喜欢
随机推荐
微信小程序云开发 | 城市信息管理
银行适用:此文能够突破你的运维流程管理问题
【开发者必看】【push kit】推送服务典型问题合集3
Hello, my new name is "Bronze Lock/Tongsuo"
Mysql execution principle analysis
[Use of Qt Designer tool]
【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
【总结】1396- 60+个 VSCode 插件,打造好用的编辑器
【HMS core】【FAQ】Account Kit、MDM能力、push Kit典型问题合集6
AWS console
[Summary] 1396- 60+ VSCode plugins to create a useful editor
中集世联达工业级成熟航运港口人工智能AI产品规模化应用,打造新一代高效能智慧港口和创新数字港口,全球港航人工智能能领军者中集飞瞳
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
【剑指 Offer】剑指 Offer 22. 链表中倒数第k个节点
DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计
Immersive experience iFLYTEK 2022 Consumer Expo "Official Designated Product"
【PHPWord】PHPOffice 套件之PHPWord快速入门
Recommended Books | Recommend 3 database books with rave reviews
第14章 类型信息
攻防世界web-Cat
p>








