parallelStream throwing Caused by: java.util.concurrent.TimeoutException: null
I have created a REST API Service within which I am using Java8 parallelStream like as shown below
employeesDetails = employeesDetailsList.parallelStream().map(getEmployeesDetails ).collect(Collectors.toList());
I am using parallelStream because it needs to iterate huge records and marshall it to a different response. The API is working fine, but the problem is lets say the REST API takes 1 min time to execute successfully. If one hits the same REST API service multiple times at the server side its executing multiple times and throwing exception Caused by: java.util.concurrent.TimeoutException: null
Can anyone please help me on this. Also like to know whether parallelStream is the correct choice for this scenario
java rest java-8 java-stream
|
show 5 more comments
I have created a REST API Service within which I am using Java8 parallelStream like as shown below
employeesDetails = employeesDetailsList.parallelStream().map(getEmployeesDetails ).collect(Collectors.toList());
I am using parallelStream because it needs to iterate huge records and marshall it to a different response. The API is working fine, but the problem is lets say the REST API takes 1 min time to execute successfully. If one hits the same REST API service multiple times at the server side its executing multiple times and throwing exception Caused by: java.util.concurrent.TimeoutException: null
Can anyone please help me on this. Also like to know whether parallelStream is the correct choice for this scenario
java rest java-8 java-stream
Please show a complete example and the complete stack trace.
– tgdavies
Jan 1 at 9:54
2
TimeoutExceptions you're looking at are not relate toparallelStream
. Look at the API response times and ensure reduced network latencies to achieve whatever you're trying to. Or else increase the timeout in worst case.
– nullpointer
Jan 1 at 9:54
1
parallelStream
is not appropriate here, as it doesn't given you enough control over the number of concurrent requests you are making to your REST server -- it is likely that you are overwhelming it.
– tgdavies
Jan 1 at 10:01
@tgdavies but when I use normalstream()
then it is taking around 4 min
– Alex Man
Jan 1 at 10:12
1
You should use an executor service with a known number of threads, rather than a parallel stream. Not everything in Java has to be done with a stream. Also, make sure all requests to the REST server are handled together, not separately for each hit on your service.
– RealSkeptic
Jan 1 at 10:14
|
show 5 more comments
I have created a REST API Service within which I am using Java8 parallelStream like as shown below
employeesDetails = employeesDetailsList.parallelStream().map(getEmployeesDetails ).collect(Collectors.toList());
I am using parallelStream because it needs to iterate huge records and marshall it to a different response. The API is working fine, but the problem is lets say the REST API takes 1 min time to execute successfully. If one hits the same REST API service multiple times at the server side its executing multiple times and throwing exception Caused by: java.util.concurrent.TimeoutException: null
Can anyone please help me on this. Also like to know whether parallelStream is the correct choice for this scenario
java rest java-8 java-stream
I have created a REST API Service within which I am using Java8 parallelStream like as shown below
employeesDetails = employeesDetailsList.parallelStream().map(getEmployeesDetails ).collect(Collectors.toList());
I am using parallelStream because it needs to iterate huge records and marshall it to a different response. The API is working fine, but the problem is lets say the REST API takes 1 min time to execute successfully. If one hits the same REST API service multiple times at the server side its executing multiple times and throwing exception Caused by: java.util.concurrent.TimeoutException: null
Can anyone please help me on this. Also like to know whether parallelStream is the correct choice for this scenario
java rest java-8 java-stream
java rest java-8 java-stream
asked Jan 1 at 9:50
Alex ManAlex Man
1,3411149107
1,3411149107
Please show a complete example and the complete stack trace.
– tgdavies
Jan 1 at 9:54
2
TimeoutExceptions you're looking at are not relate toparallelStream
. Look at the API response times and ensure reduced network latencies to achieve whatever you're trying to. Or else increase the timeout in worst case.
– nullpointer
Jan 1 at 9:54
1
parallelStream
is not appropriate here, as it doesn't given you enough control over the number of concurrent requests you are making to your REST server -- it is likely that you are overwhelming it.
– tgdavies
Jan 1 at 10:01
@tgdavies but when I use normalstream()
then it is taking around 4 min
– Alex Man
Jan 1 at 10:12
1
You should use an executor service with a known number of threads, rather than a parallel stream. Not everything in Java has to be done with a stream. Also, make sure all requests to the REST server are handled together, not separately for each hit on your service.
– RealSkeptic
Jan 1 at 10:14
|
show 5 more comments
Please show a complete example and the complete stack trace.
– tgdavies
Jan 1 at 9:54
2
TimeoutExceptions you're looking at are not relate toparallelStream
. Look at the API response times and ensure reduced network latencies to achieve whatever you're trying to. Or else increase the timeout in worst case.
– nullpointer
Jan 1 at 9:54
1
parallelStream
is not appropriate here, as it doesn't given you enough control over the number of concurrent requests you are making to your REST server -- it is likely that you are overwhelming it.
– tgdavies
Jan 1 at 10:01
@tgdavies but when I use normalstream()
then it is taking around 4 min
– Alex Man
Jan 1 at 10:12
1
You should use an executor service with a known number of threads, rather than a parallel stream. Not everything in Java has to be done with a stream. Also, make sure all requests to the REST server are handled together, not separately for each hit on your service.
– RealSkeptic
Jan 1 at 10:14
Please show a complete example and the complete stack trace.
– tgdavies
Jan 1 at 9:54
Please show a complete example and the complete stack trace.
– tgdavies
Jan 1 at 9:54
2
2
TimeoutExceptions you're looking at are not relate to
parallelStream
. Look at the API response times and ensure reduced network latencies to achieve whatever you're trying to. Or else increase the timeout in worst case.– nullpointer
Jan 1 at 9:54
TimeoutExceptions you're looking at are not relate to
parallelStream
. Look at the API response times and ensure reduced network latencies to achieve whatever you're trying to. Or else increase the timeout in worst case.– nullpointer
Jan 1 at 9:54
1
1
parallelStream
is not appropriate here, as it doesn't given you enough control over the number of concurrent requests you are making to your REST server -- it is likely that you are overwhelming it.– tgdavies
Jan 1 at 10:01
parallelStream
is not appropriate here, as it doesn't given you enough control over the number of concurrent requests you are making to your REST server -- it is likely that you are overwhelming it.– tgdavies
Jan 1 at 10:01
@tgdavies but when I use normal
stream()
then it is taking around 4 min– Alex Man
Jan 1 at 10:12
@tgdavies but when I use normal
stream()
then it is taking around 4 min– Alex Man
Jan 1 at 10:12
1
1
You should use an executor service with a known number of threads, rather than a parallel stream. Not everything in Java has to be done with a stream. Also, make sure all requests to the REST server are handled together, not separately for each hit on your service.
– RealSkeptic
Jan 1 at 10:14
You should use an executor service with a known number of threads, rather than a parallel stream. Not everything in Java has to be done with a stream. Also, make sure all requests to the REST server are handled together, not separately for each hit on your service.
– RealSkeptic
Jan 1 at 10:14
|
show 5 more comments
0
active
oldest
votes
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',
autoActivateHeartbeat: false,
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
});
}
});
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%2f53994475%2fparallelstream-throwing-caused-by-java-util-concurrent-timeoutexception-null%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53994475%2fparallelstream-throwing-caused-by-java-util-concurrent-timeoutexception-null%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
Please show a complete example and the complete stack trace.
– tgdavies
Jan 1 at 9:54
2
TimeoutExceptions you're looking at are not relate to
parallelStream
. Look at the API response times and ensure reduced network latencies to achieve whatever you're trying to. Or else increase the timeout in worst case.– nullpointer
Jan 1 at 9:54
1
parallelStream
is not appropriate here, as it doesn't given you enough control over the number of concurrent requests you are making to your REST server -- it is likely that you are overwhelming it.– tgdavies
Jan 1 at 10:01
@tgdavies but when I use normal
stream()
then it is taking around 4 min– Alex Man
Jan 1 at 10:12
1
You should use an executor service with a known number of threads, rather than a parallel stream. Not everything in Java has to be done with a stream. Also, make sure all requests to the REST server are handled together, not separately for each hit on your service.
– RealSkeptic
Jan 1 at 10:14