Rest Web Service Interface - Multithreaded
up vote
0
down vote
favorite
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
add a comment |
up vote
0
down vote
favorite
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
Might be a duplicate of stackoverflow.com/questions/40794181/…
– 孙兴斌
Nov 10 at 18:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
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
java multithreading
asked Nov 10 at 18:14
Pete Long
186
186
Might be a duplicate of stackoverflow.com/questions/40794181/…
– 孙兴斌
Nov 10 at 18:18
add a comment |
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
add a comment |
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.
Hi Andrei. Thank you for a prompt answer.
– Pete Long
Nov 10 at 21:23
add a comment |
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
Hi Deadpool. Thank you for a prompt answer.
– Pete Long
Nov 10 at 19:39
add a comment |
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
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
add a comment |
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.
Hi Andrei. Thank you for a prompt answer.
– Pete Long
Nov 10 at 21:23
add a comment |
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.
Hi Andrei. Thank you for a prompt answer.
– Pete Long
Nov 10 at 21:23
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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
Hi Deadpool. Thank you for a prompt answer.
– Pete Long
Nov 10 at 19:39
add a comment |
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
Hi Deadpool. Thank you for a prompt answer.
– Pete Long
Nov 10 at 19:39
add a comment |
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
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
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
add a comment |
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
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Might be a duplicate of stackoverflow.com/questions/40794181/…
– 孙兴斌
Nov 10 at 18:18