0

I want to increase the timeout of an API at the controller level. For all API we can do by mentioning the following in my yml file:

ribbon:
  ReadTimeout: 30000
  ConnectTimeout: 30000

But I want timeout increase timeout for a particular API. As it is a long process API. How can we achieve this?

@GetMapping(value = { "", "/" })
    public ResponseEntity<Page<DBInventoryMasterEntity>> fetch() {
        Page<DBInventoryMasterEntity> returnList = null;
            returnList = inventoryService.findByCustomerCode();
        return ResponseEntity.ok(returnList);
    }
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
avinash kumar
  • 475
  • 6
  • 10

1 Answers1

0

You can try these two methods:

  1. Return a Callable<>. See this answer.
  2. Use @Transactional annotation which takes a timeout (in seconds) parameter
    @GetMapping(value = { "", "/" })
    @Timed
    @Transactional(timeout = 120)  // 2 minutes
    public ResponseEntity<Page<DBInventoryMasterEntity>> fetch() {
        // your code
    }
Ronij Pandey
  • 133
  • 6