Search code examples
javaspring-mvcspring-restcontroller

how do I allow only one session to Spring REST web service at one time?


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.


Solution

  • 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.