当前位置:网站首页>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;边栏推荐
- 较真儿学源码系列-InheritableThreadLocal(逐行源码带你分析作者思路)
- How to use console Log print text?
- Example explanation: move graph explorer to jupyterlab
- 有意思了!数据库也搞Serverless!
- 产品模块化设计的前世今生
- Object creation
- Easycvr accesses the equipment through the national standard gb28181 protocol. What is the reason for the automatic streaming of the equipment?
- Interesting! Database is also serverless!
- [untitled]
- List is divided into sets that meet and do not meet conditions (partitioningby)
猜你喜欢
随机推荐
较真儿学源码系列-InheritableThreadLocal(逐行源码带你分析作者思路)
JS proxy
Optimization of video streaming with repeated requests in the case of unstable easygbs network
JS 之 常用内置类的使用
3D全景模型展示可视化技术演示
DDR4 test-2
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
How to use console Log print text?
JS ternary expression complex condition judgment
Uni app wechat applet one click login to obtain permission function
GC垃圾回收
SQL getting started plan-1-select
list大集合等比分割成多个小list集合
list分割成满足和不满足条件的集合(partitioningBy)
Test self-study people must see: how to find test items in software testing?
Easycvr accesses the equipment through the national standard gb28181 protocol. What is the reason for the automatic streaming of the equipment?
qobject_ Cast usage
Redis installation and startup in Windows environment (background startup)
P2433 【深基1-2】小学数学 N 合一


![[research materials] national second-hand housing market monthly report January 2022 - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)





