Re: Threads and HttpsURLConnection underlying shared connection? [SOLVED]
Re: Threads and HttpsURLConnection underlying shared connection? [SOLVED]
- Subject: Re: Threads and HttpsURLConnection underlying shared connection? [SOLVED]
- From: Hugi Thordarson <email@hidden>
- Date: Wed, 18 May 2005 17:12:48 +0000
Or if you're like me and like to reduce dependencies on third party
jars, you might want to try Helge Staedtler's threaded URL fetching
class, available here:
http://www.wocode.com/cgi-bin/WebObjects/WOCode.woa/wa/ShareCodeItem?
itemId=363
I've used it with great results in several projects, thanks Helge :-D.
Cheers,
Hugi
// Hugi Thordarson
// LandeyĆ°a
// http://www.karlmenn.is/
On 18.5.2005, at 16:36, Kieran Kelleher wrote:
FYI,
A solution to this problem can be implemented using
org.apache.commons.httpclient open source project..... really
excellent http client class that delivers on multi-threaded parallel
use of connections and ease of use. IMHO, it is easier to implement
than java's built-in HttpsURLConnection.
http://jakarta.apache.org/commons/httpclient/3.0/apidocs/index.html
If you have a site that handles simultaneous users processing credit
cards for example, then this http client allows all parts of you app
to use a single http client instance (a static in your class for
example) to simultaneously process transactions against a service
provider without encountering long delays waiting for an underlying
shared connection as is the case with HttpsURLConnection class.
The HttpClient class can be initialized with a
MultiThreadedHttpConnectionManager argument in the constructor. The
conn manager can be told to allow up to N connections to the same host
and X total open connections.
Very easy to use. Highly recommended.
-Kieran
________________________________________________________________
Blog: http://webobjects.webhop.org/
On May 17, 2005, at 1:04 PM, Kieran Kelleher wrote:
In my java Web Application I have a class that processes credit card
transactions against a service provider (viaklix).
For each transaction, I create two threads .... a managerThread and a
processorThread. The processorThread does the actual transaction
processing which basically creates a HttpsURLConnection, writes out
(POST) form data to our service provider and reads the response. The
managerThread monitors the processorThread to make sure it completes
its task within allotted timeOut using join and interrupt.
My problem is that when I initiate a number of transactions (multiple
transaction classes each with two threads), the instances of
HttpsURLConnection in the separate threads each seem to have to wait
for other threads' HttpsURLConnection instances to finish reading
their response before it can get a connection. I have confirmed this
by logging the threads' activities.
Is it not possible to have multiple threads simultaneously connected
and performing HttpsURLConnection POST/RESPONSE from my app (acting
as a client) to the same provider (www.viaklix.com)??
Any suggestions as to how I can alleviate this situation .... am I
missing some basic concept here? Is there some single underlying
shared connection that my HttpsURLConnection instances are
constrained by?
Regards, Kieran
-Kieran
________________________________________________________________
My hardware/software configurations (in case they are relevant to the
problem):
Dev Config = OS X 10.3.7 / Java 1.4.2_05 / WO 5.2.3 / XCode v1.5 /
MySQL 4.0.23 / Connector-J 3.0.16
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden