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