Rest Web Service Interface - Multithreaded











up vote
0
down vote

favorite
1












Below is a snippet of an existing Rest Interface implementation.



@RestController
@RequestMapping("/login")
public class LoginController {


@Autowired
private LoginProcessor loginProcessor;

@RequestMapping(
consumes = MediaType.TEXT_XML_VALUE,
produces = { MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_JSON_VALUE },
value = "/v1/login",
method = RequestMethod.POST)

public LoginResponse loginRequest(
@RequestBody String credentials) throws JAXBException {

return loginProcessor.request(credentials);
}
}


If the REST call to loginRequest() is initiated from different clients, and possibly, at the same time :-



1) Will a new thread be created to handle each request. Therefore, all requests are being processed concurrently ?



or



2) Is there one thread to handle all requests, which would mean only loginRequest() is being executed at any one time, and other request are queued up ?



I would ideally like to the interface to be able to handle multiple requests at any one time.



Thank you for your help in both clarifying and furthering my understanding on the subject.



Pete










share|improve this question






















  • Might be a duplicate of stackoverflow.com/questions/40794181/…
    – 孙兴斌
    Nov 10 at 18:18

















up vote
0
down vote

favorite
1












Below is a snippet of an existing Rest Interface implementation.



@RestController
@RequestMapping("/login")
public class LoginController {


@Autowired
private LoginProcessor loginProcessor;

@RequestMapping(
consumes = MediaType.TEXT_XML_VALUE,
produces = { MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_JSON_VALUE },
value = "/v1/login",
method = RequestMethod.POST)

public LoginResponse loginRequest(
@RequestBody String credentials) throws JAXBException {

return loginProcessor.request(credentials);
}
}


If the REST call to loginRequest() is initiated from different clients, and possibly, at the same time :-



1) Will a new thread be created to handle each request. Therefore, all requests are being processed concurrently ?



or



2) Is there one thread to handle all requests, which would mean only loginRequest() is being executed at any one time, and other request are queued up ?



I would ideally like to the interface to be able to handle multiple requests at any one time.



Thank you for your help in both clarifying and furthering my understanding on the subject.



Pete










share|improve this question






















  • Might be a duplicate of stackoverflow.com/questions/40794181/…
    – 孙兴斌
    Nov 10 at 18:18















up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





Below is a snippet of an existing Rest Interface implementation.



@RestController
@RequestMapping("/login")
public class LoginController {


@Autowired
private LoginProcessor loginProcessor;

@RequestMapping(
consumes = MediaType.TEXT_XML_VALUE,
produces = { MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_JSON_VALUE },
value = "/v1/login",
method = RequestMethod.POST)

public LoginResponse loginRequest(
@RequestBody String credentials) throws JAXBException {

return loginProcessor.request(credentials);
}
}


If the REST call to loginRequest() is initiated from different clients, and possibly, at the same time :-



1) Will a new thread be created to handle each request. Therefore, all requests are being processed concurrently ?



or



2) Is there one thread to handle all requests, which would mean only loginRequest() is being executed at any one time, and other request are queued up ?



I would ideally like to the interface to be able to handle multiple requests at any one time.



Thank you for your help in both clarifying and furthering my understanding on the subject.



Pete










share|improve this question













Below is a snippet of an existing Rest Interface implementation.



@RestController
@RequestMapping("/login")
public class LoginController {


@Autowired
private LoginProcessor loginProcessor;

@RequestMapping(
consumes = MediaType.TEXT_XML_VALUE,
produces = { MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_JSON_VALUE },
value = "/v1/login",
method = RequestMethod.POST)

public LoginResponse loginRequest(
@RequestBody String credentials) throws JAXBException {

return loginProcessor.request(credentials);
}
}


If the REST call to loginRequest() is initiated from different clients, and possibly, at the same time :-



1) Will a new thread be created to handle each request. Therefore, all requests are being processed concurrently ?



or



2) Is there one thread to handle all requests, which would mean only loginRequest() is being executed at any one time, and other request are queued up ?



I would ideally like to the interface to be able to handle multiple requests at any one time.



Thank you for your help in both clarifying and furthering my understanding on the subject.



Pete







java multithreading






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 18:14









Pete Long

186




186












  • Might be a duplicate of stackoverflow.com/questions/40794181/…
    – 孙兴斌
    Nov 10 at 18:18




















  • Might be a duplicate of stackoverflow.com/questions/40794181/…
    – 孙兴斌
    Nov 10 at 18:18


















Might be a duplicate of stackoverflow.com/questions/40794181/…
– 孙兴斌
Nov 10 at 18:18






Might be a duplicate of stackoverflow.com/questions/40794181/…
– 孙兴斌
Nov 10 at 18:18














3 Answers
3






active

oldest

votes

















up vote
1
down vote













You can search stack overflow for this type of question as it has been answered before. You can read these answers:
https://stackoverflow.com/a/7457252/10632970
https://stackoverflow.com/a/17236345/10632970



Good luck with your studies.






share|improve this answer





















  • Hi Andrei. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 21:23


















up vote
1
down vote













Every application should run in server either web server (tomcat) or application server (web logic), by default tomcat web container will have 200 threads ( you can adjust as your wish), so 200 threads can process concurrently at a time in tomcat



For every input request will be taken by web container thread and next to dispatcher servlet to corresponding controller class






share|improve this answer





















  • Hi Deadpool. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 19:39


















up vote
1
down vote













I suppose you are using spring framework ( as you have used Autowired and other annotations). Thus to ans your ques: Yes spring will create new thread for each new request. Kindly refer to this answer, this should solve your queries



https://stackoverflow.com/a/17236345/7622687






share|improve this answer





















  • Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
    – Pete Long
    Nov 10 at 19:40












  • Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
    – NiksVij
    Nov 13 at 16:01











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241987%2frest-web-service-interface-multithreaded%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













You can search stack overflow for this type of question as it has been answered before. You can read these answers:
https://stackoverflow.com/a/7457252/10632970
https://stackoverflow.com/a/17236345/10632970



Good luck with your studies.






share|improve this answer





















  • Hi Andrei. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 21:23















up vote
1
down vote













You can search stack overflow for this type of question as it has been answered before. You can read these answers:
https://stackoverflow.com/a/7457252/10632970
https://stackoverflow.com/a/17236345/10632970



Good luck with your studies.






share|improve this answer





















  • Hi Andrei. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 21:23













up vote
1
down vote










up vote
1
down vote









You can search stack overflow for this type of question as it has been answered before. You can read these answers:
https://stackoverflow.com/a/7457252/10632970
https://stackoverflow.com/a/17236345/10632970



Good luck with your studies.






share|improve this answer












You can search stack overflow for this type of question as it has been answered before. You can read these answers:
https://stackoverflow.com/a/7457252/10632970
https://stackoverflow.com/a/17236345/10632970



Good luck with your studies.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 18:19









Andrei Dumitrescu-Tudor

1296




1296












  • Hi Andrei. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 21:23


















  • Hi Andrei. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 21:23
















Hi Andrei. Thank you for a prompt answer.
– Pete Long
Nov 10 at 21:23




Hi Andrei. Thank you for a prompt answer.
– Pete Long
Nov 10 at 21:23












up vote
1
down vote













Every application should run in server either web server (tomcat) or application server (web logic), by default tomcat web container will have 200 threads ( you can adjust as your wish), so 200 threads can process concurrently at a time in tomcat



For every input request will be taken by web container thread and next to dispatcher servlet to corresponding controller class






share|improve this answer





















  • Hi Deadpool. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 19:39















up vote
1
down vote













Every application should run in server either web server (tomcat) or application server (web logic), by default tomcat web container will have 200 threads ( you can adjust as your wish), so 200 threads can process concurrently at a time in tomcat



For every input request will be taken by web container thread and next to dispatcher servlet to corresponding controller class






share|improve this answer





















  • Hi Deadpool. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 19:39













up vote
1
down vote










up vote
1
down vote









Every application should run in server either web server (tomcat) or application server (web logic), by default tomcat web container will have 200 threads ( you can adjust as your wish), so 200 threads can process concurrently at a time in tomcat



For every input request will be taken by web container thread and next to dispatcher servlet to corresponding controller class






share|improve this answer












Every application should run in server either web server (tomcat) or application server (web logic), by default tomcat web container will have 200 threads ( you can adjust as your wish), so 200 threads can process concurrently at a time in tomcat



For every input request will be taken by web container thread and next to dispatcher servlet to corresponding controller class







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 18:27









Deadpool

2,8862321




2,8862321












  • Hi Deadpool. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 19:39


















  • Hi Deadpool. Thank you for a prompt answer.
    – Pete Long
    Nov 10 at 19:39
















Hi Deadpool. Thank you for a prompt answer.
– Pete Long
Nov 10 at 19:39




Hi Deadpool. Thank you for a prompt answer.
– Pete Long
Nov 10 at 19:39










up vote
1
down vote













I suppose you are using spring framework ( as you have used Autowired and other annotations). Thus to ans your ques: Yes spring will create new thread for each new request. Kindly refer to this answer, this should solve your queries



https://stackoverflow.com/a/17236345/7622687






share|improve this answer





















  • Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
    – Pete Long
    Nov 10 at 19:40












  • Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
    – NiksVij
    Nov 13 at 16:01















up vote
1
down vote













I suppose you are using spring framework ( as you have used Autowired and other annotations). Thus to ans your ques: Yes spring will create new thread for each new request. Kindly refer to this answer, this should solve your queries



https://stackoverflow.com/a/17236345/7622687






share|improve this answer





















  • Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
    – Pete Long
    Nov 10 at 19:40












  • Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
    – NiksVij
    Nov 13 at 16:01













up vote
1
down vote










up vote
1
down vote









I suppose you are using spring framework ( as you have used Autowired and other annotations). Thus to ans your ques: Yes spring will create new thread for each new request. Kindly refer to this answer, this should solve your queries



https://stackoverflow.com/a/17236345/7622687






share|improve this answer












I suppose you are using spring framework ( as you have used Autowired and other annotations). Thus to ans your ques: Yes spring will create new thread for each new request. Kindly refer to this answer, this should solve your queries



https://stackoverflow.com/a/17236345/7622687







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 18:33









NiksVij

285




285












  • Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
    – Pete Long
    Nov 10 at 19:40












  • Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
    – NiksVij
    Nov 13 at 16:01


















  • Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
    – Pete Long
    Nov 10 at 19:40












  • Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
    – NiksVij
    Nov 13 at 16:01
















Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
– Pete Long
Nov 10 at 19:40






Hi NiksVij. Thank you for a prompt answer. My is deployed in WebLogic container so from the response, the WebLogic will create a new thread to process each request. Is there a way to confirm this is happening on WebLogic or some other way. ?
– Pete Long
Nov 10 at 19:40














Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
– NiksVij
Nov 13 at 16:01




Hey Pete. I don't have much experience on WebLogic , but i think you should be able to confirm the above by taking help from this: stackoverflow.com/questions/1323408/… and adding few log statements . Hope it helps :)
– NiksVij
Nov 13 at 16:01


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241987%2frest-web-service-interface-multithreaded%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation