当前位置:网站首页>Solution for processing overtime orders (Overtime unpaid)
Solution for processing overtime orders (Overtime unpaid)
2022-07-03 02:04:00 【Small brother's advanced】
1. Overtime unpaid order processing
1.1 Demand analysis
Orders that have not been paid beyond the time limit , We need to deal with overtime orders : First call wechat payment api, Query the payment status of this order . Call to close the order if not paid api, And modify the order status to closed , And roll back the inventory . If the order has been paid , Then do the compensation operation ( Modify order status and records ).
1.2 Realize the idea
Implementation steps :
1. When generating an order ( The creation time of the order is recorded in the table )
2. According to the creation time of the order 30 Minutes , If the order is not paid
3. Put the order generation message into the dead letter queue
4. Consume the messages in the dead letter queue : Delete the unpaid orders in the database , Need to modify the inventory of goods
How to get orders that exceed the time limit ? We can use delayed message queues ( Dead letter queue ) To achieve .
The so-called delayed message queue , That is, messages sent by message producers will not be consumed immediately , Instead, it can be consumed after the set time .
We can send a delay message when the order is created , Message is order number , The system will retrieve this message after a limited time , Then query the payment status of the order , Make corresponding treatment according to the results .
1.3 rabbitmq Delay message
Use RabbitMQ To implement deferred messages, you must first understand RabbitMQ Two concepts of : News TTL And dead letter Exchange, Through the combination of the two to achieve the above requirements .
1.3.1 News TTL(Time To Live)
News TTL It's the survival time of the message .RabbitMQ You can set the queue and message separately TTL. Setting the queue is the retention time when the queue has no consumers , You can also make separate settings for each individual message . Beyond this time , We think the news is dead , Call it a dead letter .
Let's create a queue queue.temp, stay Arguments Add x-message-ttl by 5000 ( In milliseconds ), Then every message that enters this queue is 5 Seconds later .
1.3.2 A dead letter exchanger Dead Letter Exchanges
A message satisfies the following conditions , It will enter the dead letter switch , Remember, this is the switch, not the queue , A switch can correspond to many queues .
(1) A message was Consumer Rejected , also reject Method parameters requeue yes false. That is to say, it will not be put in the queue again , Used by other consumers .
(2) From the above news TTL here we are , The news is out of date .
(3) The length limit of the queue is full . Messages in the front row will be discarded or thrown on the dead letter switch .
Dead Letter Exchange In fact, it is a kind of ordinary exchange, And create other exchange There is no difference . Just in a certain setting Dead Letter Exchange There are messages out of date in the queue of , Will automatically trigger message forwarding , Send to Dead Letter Exchange In the middle .
We can now test the delay queue .
(1) Create a dead letter exchange exchange.ordertimeout (fanout)
(2) Create a queue queue.ordertimeout
(3) Establish a dead letter exchange exchange.ordertimeout And queues queue.ordertimeout Binding between
(4) Create a queue queue.ordercreate,Arguments add to
x-message-ttl=10000
x-dead-letter-exchange: exchange.ordertimeout
(5) test : towards queue.ordercreate Queue add message , wait for 10 Message from in seconds queue.ordercreate The queue disappears ,
1.3.3 Delayed message processing
From message queue queue.ordertimeout Extract messages from , Execute order deletion
边栏推荐
- Socket编程
- 详细些介绍如何通过MQTT协议和华为云物联网进行通信
- When the epidemic comes, how to manage the team as a leader| Community essay solicitation
- Asian Games countdown! AI target detection helps host the Asian Games!
- 全链路数字化转型下,零售企业如何打开第二增长曲线
- stm32F407-------DMA
- File class (add / delete)
- Machine learning notes (constantly updating...)
- MySQL learning 03
- Network security - password cracking
猜你喜欢
可视化yolov5格式数据集(labelme json文件)
机器学习笔记(持续更新中。。。)
What are the key points often asked in the redis interview
小程序開發的部分功能
【Camera专题】Camera dtsi 完全解析
Rockchip3399 start auto load driver
Stm32f407 ------- IIC communication protocol
PS去除水印详解
A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?
深度(穿透)选择器 ::v-deep/deep/及 > > >
随机推荐
Missing library while loading shared libraries: libisl so. 15: cannot open shared object file: No such file
How can retail enterprises open the second growth curve under the full link digital transformation
Depth (penetration) selector:: v-deep/deep/ and > > >
查询商品案例-页面渲染数据
NCTF 2018 part Title WP (1)
mysql
How to find summer technical internship in junior year? Are you looking for a large company or a small company for technical internship?
Redis:Redis的简单使用
Analysis, use and extension of open source API gateway apisex
[camera special topic] Hal layer - brief analysis of addchannel and startchannel
Answers to ten questions about automated testing software testers must see
[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)
Network security OpenVAS
Network security - firewall
ByteDance data Lake integration practice based on Hudi
Return the only different value (de duplication)
Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
全链路数字化转型下,零售企业如何打开第二增长曲线
Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux
"Jetpack - livedata parsing"