You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Kessel, Christopher" <ck...@transunion.com> on 2011/03/04 00:14:45 UTC

Default simultaneous CXF client connections?

I'm reusing the same client across multiple threads. 

At startup I do something like this:
	factory = new JaxWsProxyFactoryBean();
	client = (MyClient) factory.create();

Then I can have lots of threads concurrently making calls on that one client:
	client.doMyThing();

I know the client is multithread safe, but I'm not sure how many internal threads the client will use for communication. How many simultaneous connections will CXF (or whatever underlying socket pool) maintain and how do I change that value?

This is with 2.2.10.

Thanks,
Chris

Re: Default simultaneous CXF client connections?

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 09 March 2011 11:21:13 AM Kessel, Christopher wrote:
> I think I found it. I'm looking at
> org.apache.cxf.transport.http.HTTPConduit.prepare() and it's asking for a
> new connection from the HttpURLConnectionFactory.createConnection(), which
> in turn does a HttpURLConnection.openConnection().
> 
> So, the short answer is, a new connection per request.

Somewhat yet.   Under the covers, HttpURLConnection does maintain a pool of 
connections that can be reused so if there is an idle Keep-Alive connection, 
it will use  that.   However, if there isn't, it will create a new connection.

Dan


> 
> FYI,
> Chris
> 
> -----Original Message-----
> From: Kessel, Christopher [mailto:ckessel@transunion.com]
> Sent: Wednesday, March 09, 2011 7:30 AM
> To: users@cxf.apache.org
> Subject: RE: Default simultaneous CXF client connections?
> 
> When you say you use the HTTPUrlConnection, does that mean there's no
> connection pool used and a new HTTPUrlConnection is created for each
> request? I'm trying to hunt through the CXF code and figure out where the
> socket communication actually takes place, but I haven't found it quite
> yet. I'm following the path of ClientProxy, assuming it's down that chain
> somewhere?
> 
> The reason I ask is two-fold:
> 1) If it only maintains 1 connection, the number of threads I have doesn't
> matter since my call to the external server is where my code spends 90% of
> its time waiting. 2) If it opens a connection per request, then I need to
> throttle my side to limit the number of connections.
> 
> I've been using the client to hit the server sort of like I'd use a JDBC
> client backed by a connection pool. In other words, fire and forget and
> the pool take care of the connection end of things :). I'm thinking that's
> probably not appropriate for a CXF client.
> 
> Thanks,
> Chris
> 
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Friday, March 04, 2011 12:52 PM
> To: users@cxf.apache.org
> Cc: Kessel, Christopher
> Subject: Re: Default simultaneous CXF client connections?
> 
> On Thursday 03 March 2011 6:14:45 PM Kessel, Christopher wrote:
> > I'm reusing the same client across multiple threads.
> > 
> > At startup I do something like this:
> > 	factory = new JaxWsProxyFactoryBean();
> > 	client = (MyClient) factory.create();
> > 
> > Then I can have lots of threads concurrently making calls on that one
> > client: client.doMyThing();
> > 
> > I know the client is multithread safe, but I'm not sure how many internal
> > threads the client will use for communication. How many simultaneous
> > connections will CXF (or whatever underlying socket pool) maintain and
> > how do I change that value?
> 
> We really just use the HTTPUrlConnection object to connect to the Server.
> Thus, anything that you may find on google about that would apply to CXF as
> well.     I honestly don't know the answer.  :-(

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

RE: Default simultaneous CXF client connections?

Posted by "Kessel, Christopher" <ck...@transunion.com>.
I think I found it. I'm looking at org.apache.cxf.transport.http.HTTPConduit.prepare() and it's asking for a new connection from the HttpURLConnectionFactory.createConnection(), which in turn does a HttpURLConnection.openConnection().

So, the short answer is, a new connection per request.

FYI,
Chris

-----Original Message-----
From: Kessel, Christopher [mailto:ckessel@transunion.com] 
Sent: Wednesday, March 09, 2011 7:30 AM
To: users@cxf.apache.org
Subject: RE: Default simultaneous CXF client connections?

When you say you use the HTTPUrlConnection, does that mean there's no connection pool used and a new HTTPUrlConnection is created for each request? I'm trying to hunt through the CXF code and figure out where the socket communication actually takes place, but I haven't found it quite yet. I'm following the path of ClientProxy, assuming it's down that chain somewhere?

The reason I ask is two-fold:
1) If it only maintains 1 connection, the number of threads I have doesn't matter since my call to the external server is where my code spends 90% of its time waiting.
2) If it opens a connection per request, then I need to throttle my side to limit the number of connections.

I've been using the client to hit the server sort of like I'd use a JDBC client backed by a connection pool. In other words, fire and forget and the pool take care of the connection end of things :). I'm thinking that's probably not appropriate for a CXF client.

Thanks,
Chris

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Friday, March 04, 2011 12:52 PM
To: users@cxf.apache.org
Cc: Kessel, Christopher
Subject: Re: Default simultaneous CXF client connections?

On Thursday 03 March 2011 6:14:45 PM Kessel, Christopher wrote:
> I'm reusing the same client across multiple threads.
> 
> At startup I do something like this:
> 	factory = new JaxWsProxyFactoryBean();
> 	client = (MyClient) factory.create();
> 
> Then I can have lots of threads concurrently making calls on that one
> client: client.doMyThing();
> 
> I know the client is multithread safe, but I'm not sure how many internal
> threads the client will use for communication. How many simultaneous
> connections will CXF (or whatever underlying socket pool) maintain and how
> do I change that value?

We really just use the HTTPUrlConnection object to connect to the Server.  
Thus, anything that you may find on google about that would apply to CXF as 
well.     I honestly don't know the answer.  :-(
 
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

RE: Default simultaneous CXF client connections?

Posted by "Kessel, Christopher" <ck...@transunion.com>.
When you say you use the HTTPUrlConnection, does that mean there's no connection pool used and a new HTTPUrlConnection is created for each request? I'm trying to hunt through the CXF code and figure out where the socket communication actually takes place, but I haven't found it quite yet. I'm following the path of ClientProxy, assuming it's down that chain somewhere?

The reason I ask is two-fold:
1) If it only maintains 1 connection, the number of threads I have doesn't matter since my call to the external server is where my code spends 90% of its time waiting.
2) If it opens a connection per request, then I need to throttle my side to limit the number of connections.

I've been using the client to hit the server sort of like I'd use a JDBC client backed by a connection pool. In other words, fire and forget and the pool take care of the connection end of things :). I'm thinking that's probably not appropriate for a CXF client.

Thanks,
Chris

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Friday, March 04, 2011 12:52 PM
To: users@cxf.apache.org
Cc: Kessel, Christopher
Subject: Re: Default simultaneous CXF client connections?

On Thursday 03 March 2011 6:14:45 PM Kessel, Christopher wrote:
> I'm reusing the same client across multiple threads.
> 
> At startup I do something like this:
> 	factory = new JaxWsProxyFactoryBean();
> 	client = (MyClient) factory.create();
> 
> Then I can have lots of threads concurrently making calls on that one
> client: client.doMyThing();
> 
> I know the client is multithread safe, but I'm not sure how many internal
> threads the client will use for communication. How many simultaneous
> connections will CXF (or whatever underlying socket pool) maintain and how
> do I change that value?

We really just use the HTTPUrlConnection object to connect to the Server.  
Thus, anything that you may find on google about that would apply to CXF as 
well.     I honestly don't know the answer.  :-(
 
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

Re: Default simultaneous CXF client connections?

Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 03 March 2011 6:14:45 PM Kessel, Christopher wrote:
> I'm reusing the same client across multiple threads.
> 
> At startup I do something like this:
> 	factory = new JaxWsProxyFactoryBean();
> 	client = (MyClient) factory.create();
> 
> Then I can have lots of threads concurrently making calls on that one
> client: client.doMyThing();
> 
> I know the client is multithread safe, but I'm not sure how many internal
> threads the client will use for communication. How many simultaneous
> connections will CXF (or whatever underlying socket pool) maintain and how
> do I change that value?

We really just use the HTTPUrlConnection object to connect to the Server.  
Thus, anything that you may find on google about that would apply to CXF as 
well.     I honestly don't know the answer.  :-(
 
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

Re: Default simultaneous CXF client connections?

Posted by eaudet <ea...@jarics.com>.
Hi Chris,
This is great but you still start a jetty instance. I do not want that. I
simply want to call CXF service code without running a jetty instance. Any
idea?
- Erick

--
View this message in context: http://cxf.547215.n5.nabble.com/Calling-Interceptor-chain-directly-tp3403562p3409563.html
Sent from the cxf-user mailing list archive at Nabble.com.