Considering the following code:
@RestController
@RequestMapping("/requestLimit")
public class TestController {
@Autowired
private TestService service;
@GetMapping("/max3")
public String max3requests() {
return service.call();
}
}
@Service
public class TestService {
public String call() {
//some business logic here
return response;
}
}
What i want to accomplish is that if the method call from the TestService is being executed by 3 threads at the same time, the next execution generate a response with a HttpStatus.TOO_MANY_REQUESTS code.
SemaphoreWhich is designed for this.