当前位置:网站首页>How to prevent repeated submission of new orders
How to prevent repeated submission of new orders
2022-07-01 19:54:00 【Ink stained with frost】
The last article wrote idempotent anti shake to prevent repeated submissions , It can effectively prevent continuous click submission , But now there is a situation , The submitted data processing return timeout is caused by the slow network or background server , Wait a little bit 1 Submit minutes or even minutes later , Idempotent anti shake does not work , Order generation multiple times .
To solve this problem , When I entered the order page, I requested a UUID, Unless you re-enter the page UUID It won't change , Then submit with this UUID To request , If REIDS Should be UUID If there is a duplicate request , There is no such thing as the background will receive UUID Deposit in REDIS in , If the processing fails, you still need to remove this KEY.
The reference codes are as follows :
String key= MessageFormat.format("INSERT:HYKCZD:{0}:{1}",vo.getTenantId(),vo.getDjbh());
if(redisService.haskey(key)) throw new BusinessException(" This page request has been processed , Do not submit again ");
redisService.setCacheObject(key,vo.getZdr()+"-"+getDateTime(),7, TimeUnit.DAYS);
PosVipCzsz czsz=czszMapper.selectById(vo.getCzszId());
if(czsz.getType()==0){
vo.setJe1(czsz.getJe2());
vo.setJe2(czsz.getJe());
vo.setJe3(czsz.getJe1());
}else{
validObjectParam(vo, VpczdVO.class, "je2","je3");
Double je1=add(vo.getJe2(), vo.getJe3());
vo.setJe1(je1);
}
String host=getHost(),url="pos/vpczd/cz",json= JSON.toJSONString(vo);
JsonResult jsonResult= doGetJsonResult$post(host, url, json);
if(!jsonResult.isSuccess()) {
redisService.deleteObject(key);
throw new DataIntefaceException(jsonResult.getMsg());
}
return 1;
边栏推荐
- How to add transactions in JDBC
- How to correctly use vertx to operate redis (3.9.4 with source code analysis)
- 1592 example 1 King (sgu223 loj10170 luogu1896 increase + / provincial election -) violent thinking pressure DP 01 Backpack
- Optimization of video streaming with repeated requests in the case of unstable easygbs network
- STC 32位8051单片机开发实例教程 三 程序编译设置与下载
- CMU AI PhD first year summary
- Uni app wechat applet one click login to obtain permission function
- SwiftUI 4 新功能大全之 Toggle与 Mixed Toggle 多个绑定组件
- JS ternary expression complex condition judgment
- JS proxy
猜你喜欢
[untitled]
Salesmartly has some tricks for Facebook chat!
Redis installation and startup in Windows environment (background startup)
Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"
Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
开发那些事儿:EasyCVR集群设备管理页面功能展示优化
Shell advanced
Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
自定义插入页面标签以及实现类似通讯录的首字母搜索
1592 example 1 King (sgu223 loj10170 luogu1896 increase + / provincial election -) violent thinking pressure DP 01 Backpack
随机推荐
How to add transactions in JDBC
#yyds干货盘点#SQL聚合查询方法总结
Uni app product classification
Simplified pinduoduo product data
PowerDesigner设计Name和Comment 替换
JVM内存模型
【C语言】详解 memset() 函数用法
Tensorflow reports an error, could not load dynamic library 'libcudnn so. eight
1592 example 1 King (sgu223 loj10170 luogu1896 increase + / provincial election -) violent thinking pressure DP 01 Backpack
Why must we move from Devops to bizdevops?
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
有意思了!数据库也搞Serverless!
Redo和Undo的区别
Battery simulation of gazebo robot
ModSim基本使用(Modbus模拟器)
DS Transunet:用于医学图像分割的双Swin-Transformer U-Net
一个悄然崛起的国产软件,低调又强大!
科技T3国产平台!成功搭载“翼辉国产实时系统SylixOS”
Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"