5

I have a spring REST web service URL http://localhost:8080/MySpringRestService/callSome

How can I restrict concurrent access to web service.

My requirement is to allow only one request to web service at one time.

Any kind of help would be appreciate.

tinlinnsoe
  • 196
  • 1
  • 2
  • 13
  • 1
    As with any Java method, you could synchronize the REST controller handler method. But this will likely give terrible performance. I recommend revisiting your design, looking to synchronize a small portion of the code rather than the whole handler. – kiwiron Jun 27 '16 at 10:36
  • Thank you kiwiron, it works. – tinlinnsoe Jun 28 '16 at 09:19

1 Answers1

3

Thanks kiwiron. It works.

Sample code is

@RequestMapping(value = RestURIConstants.GET_BALANCE_URL, 
method = RequestMethod.POST)
public synchronized @ResponseBody RESSmppModel getBalance(
        @RequestBody REQSmppModel reqSmppModel) throws Exception {

       // TODO: Code
}

But , the performance is not good.

tinlinnsoe
  • 196
  • 1
  • 2
  • 13