当前位置:网站首页>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.
边栏推荐
- SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
- 博纳影通过IPO注册:阿里腾讯是股东 受疫情冲击明显
- core sound driver详解
- 【开发者必看】【push kit】推送服务典型问题合集3
- 微博广告分布式配置中心的构建与实践(有彩蛋)
- 【AGC】构建服务1-云函数示例
- Recommendation | People who are kind to you, don't repay them by inviting them to eat
- 生物医学论文有何价值 论文中译英怎样翻译效果好
- ByteArrayInputStream class source code analysis
- mysql的多实例
猜你喜欢

【Swords Offer】Swords Offer 17. Print n digits from 1 to the largest

Fixed asset visualization intelligent management system

NC | Tao Liang Group of West Lake University - TMPRSS2 "assists" virus infection and mediates the host invasion of Clostridium sothrix hemorrhagic toxin...

CIMC Shilian Dafeitong is the global industrial artificial intelligence AI leader, the world's top AI core technology, high generalization, high robustness, sparse sample continuous learning, industri

3D机器视觉厂商的场景争夺战役

OSPF详解(3)

MySQL数据类型

WeChat Mini Program Cloud Development | Urban Information Management

CCNA-NAT协议(理论与实验练习)

生物医学论文有何价值 论文中译英怎样翻译效果好
随机推荐
Quickly build an e-commerce platform based on Amazon cloud technology serverless service - performance
Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
CCNA-NAT协议(理论与实验练习)
The use of @ symbol in MySql
Mysql执行原理剖析
LeetCode Exercise - Two Questions About Finding Sum of Array Elements
AI基础:图解Transformer
A senior with 13 years of experience in software testing, summed up 5 test employment suggestions....
Multiple instances of mysql
《自然语言处理实战入门》---- 文本样本扩展小技巧:使用回译技术进行样本增强
requet.getHeader("token") is null
常见链表题及其 Go 实现
LeetCode 练习——关于查找数组元素之和的两道题
MySql中@符号的使用
CCNA-ACL(访问控制列表)标准ACL 扩展ACL 命名ACL
Scrapy框架介绍
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
MYSQL (Basic) - An article takes you into the wonderful world of MYSQL
深化校企合作 搭建技术技能人才成长“立交桥”
卫星电话是直接与卫星通信还是通过地面站?
p>