How to send concurrent HTTP requests to a service in Java
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi All,
I'm new to Java world, So I need small help from Java geeks over here
I want to send multiple concurrent requests (say 100) to a Java web service and want to log the response back asynchronously.
I have tried searching on internet, But I was not able to find any proper answer(Maybe due to my little knowledge).
Any lead would be helpful.
Thanks in Advance for your time and inputs.
I'm new to Java world, So I need small help from Java geeks over here
I want to send multiple concurrent requests (say 100) to a Java web service and want to log the response back asynchronously.
I have tried searching on internet, But I was not able to find any proper answer(Maybe due to my little knowledge).
Any lead would be helpful.
Thanks in Advance for your time and inputs.
posted 9 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
You can make use of shell scripting to make a curl request 100 times and log back the response in a text file which might be some .text or .log file
GursewakSingh Singh
Greenhorn
Posts: 4
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
@ Sibendu, Thank you so much for your help. it is really helpful.
I will try with curl.
Here, I would like to ask is there any way using Java code to achieve this?
As I was searching, I found that there is concurrent package in Java which can provide this functionality.
But I'm still searching how to achieve that.
Thanks again
I will try with curl.
Here, I would like to ask is there any way using Java code to achieve this?
As I was searching, I found that there is concurrent package in Java which can provide this functionality.
But I'm still searching how to achieve that.
Thanks again
posted 9 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
In java , every http request is routed through a servlet dispatcher which in turn invokes a servlet.Each http request is handled as a separate operation in its own call stack ( by a thread).So multiple threads will be created by the container to take care of multiple requests.Having said so you do need to take care about your classes and their members being accessed concurrently by several threads with the help of synchronization mechanism.
posted 9 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Apache provides advanced Http java libraries to achieve more complex scenarios easily.
Details are here.
I think for your requirement, Asynch HttpClient can be better choice.
Details are here.
I think for your requirement, Asynch HttpClient can be better choice.
OCA, Java SE 8
GursewakSingh Singh
Greenhorn
Posts: 4
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
@Omkar, Thank for help.
I was trying to use Async HttpClient. I have gone documentation and sample example
Here is the sample code that I found, where we can add multiple requests.
final HttpGet[] requests = new HttpGet[] {
new HttpGet("http://www.apache.org/"),
new HttpGet("https://www.verisign.com/"),
new HttpGet("http://www.google.com/")
};
But I want to single POST request multiple time (Say 100) concurrently.
So is there any method, which provides such capability.
Thanks
I was trying to use Async HttpClient. I have gone documentation and sample example
Here is the sample code that I found, where we can add multiple requests.
final HttpGet[] requests = new HttpGet[] {
new HttpGet("http://www.apache.org/"),
new HttpGet("https://www.verisign.com/"),
new HttpGet("http://www.google.com/")
};
But I want to single POST request multiple time (Say 100) concurrently.
So is there any method, which provides such capability.
Thanks
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
There are a couple of open-source stress-test apps in Java that do that. I don't remember their names offhand, but one or 2 of them are Apache products.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
| I want my playground back. Here, I'll give you this tiny ad for it: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











