[英]We are using microservices . How to increase timeout of a particular springboot api?
I want to increase the timeout of an API at the controller level.我想在控制器级别增加 API 的超时时间。 For all API we can do by mentioning the following in my yml file:
对于所有 API,我们可以通过在我的 yml 文件中提及以下内容来完成:
ribbon:
ReadTimeout: 30000
ConnectTimeout: 30000
But I want timeout increase timeout for a particular API.但我想超时增加特定 API 的超时时间。 As it is a long process API.
因为它是一个长流程 API。 How can we achieve this?
我们怎样才能做到这一点?
@GetMapping(value = { "", "/" })
public ResponseEntity<Page<DBInventoryMasterEntity>> fetch() {
Page<DBInventoryMasterEntity> returnList = null;
returnList = inventoryService.findByCustomerCode();
return ResponseEntity.ok(returnList);
}
You can try these two methods:你可以试试这两种方法:
Callable<>
.Callable<>
。 See this answer. @GetMapping(value = { "", "/" })
@Timed
@Transactional(timeout = 120) // 2 minutes
public ResponseEntity<Page<DBInventoryMasterEntity>> fetch() {
// your code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.