I want to apply backpressure on my application webservice. So that if number of request is high say more than N
I can notify the client. Below is my controller
Before WebFlux
@RequestMapping(value = "/tasks", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseTaskModel> taskForUser(@RequestParam(value = "userId", required = true) String userId,
@RequestParam(required = false) Map<String, String> userData) {
ResponseTaskModel responseTaskModel = service.retrieveNextTaskForUser(userId.toLowerCase(), userData);
return new ResponseEntity<ResponseTaskModel>(responseTaskModel, HttpStatus.OK);
}
After WebFlux
@RequestMapping(value = "/tasks/v1", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Mono taskForUserV1(@RequestParam(value = "userId", required = true) String userId,
@RequestParam(required = false) Map<String, String> userData) {
return service.taskForUserV1(userId, userData);
}
And the service method I am calling is a blocking call to db with three queries, I'm using a postgres database.
Now how shall I apply backpressure on the Mono
object returned?