java - spring rest controller with and without callable -


first wrote simple spring rest controller

 @requestmapping(value = "/id", method = requestmethod.get)     public string getdetails(@pathvariable("id") string id) {        // wrote logic json response.... } 

second need improve performance wrote controller using callable this

@requestmapping(value = "/id", method = requestmethod.get)         public string getdetails(@pathvariable("id") string id) {           return new callable<string>(){           @override           public string call() throws exception {            // ...           return "somejsonstring";          }        }     } 

now problem when compare performance using jmeter both above methods dont see major differences.

so miss while writing callable controller?

you can not improve single request performance using callable interface, helps take more request in cases. if response type void, can use runnable instead of callable, using runnable can improve single request response time. example, if service suitable fork/join framework try it.


Comments