|
|
@@ -6,6 +6,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import space.anyi.seataStorageMicroService.service.StorageService;
|
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
/**
|
|
|
* @ProjectName: distributedSystemLearn
|
|
|
* @FileName: StorageController
|
|
|
@@ -20,6 +22,12 @@ public class StorageController {
|
|
|
//扣减库存
|
|
|
@PostMapping("/storage/reduce")
|
|
|
public ResponseResult reduce(Long productId, Integer nums){
|
|
|
+ //模拟一个延迟,使得调用链路超时,导致的调用失败
|
|
|
+ try {
|
|
|
+ TimeUnit.SECONDS.sleep(12);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
storageService.reduce(productId,nums);
|
|
|
return ResponseResult.okResult("扣减库存成功ok",null);
|
|
|
}
|