You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Mandy Warren <ma...@gmail.com> on 2014/04/15 21:02:34 UTC

Asynchronous http transport keep alive property query

Hi,

I've knocked up a unit test to prove my settings for
org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS  and
org.apache.cxf.transport.http.async.MAX_CONNECTIONS are getting set
correctly but not having much luck!

Here's the test:-

   @Test
   public void getClientUsingApacheCommonsAsync() throws Exception {
           BusFactory.getDefaultBus().setProperty
("use.async.http.conduit", true);
           BusFactory.getDefaultBus().setProperty
("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS", 10000);
           BusFactory.getDefaultBus().setProperty
("org.apache.cxf.transport.http.async.MAX_CONNECTIONS", 10000);

           WebClient.create(adfmsDummyServer.getBaseURL(),
                   Lists.newArrayList(new JacksonJsonProvider()),
true).path("/delay").accept("application/json").get();
   // TODO - add some asserts, no idea what yet!
   }

I've grep'd the cxf source code and the only place I can see a ref to
either of the MAX_XXX properties is in AsyncHTTPConduitFactory. An instance
of this class is constructed when the bus is created and then the method
setProperties() is called passing in the bus properties to then set on the
connection:-

   public AsyncHTTPConduitFactory(Bus b) {
       this();
       addListener(b);
       config.setTcpNoDelay(true);
       setProperties(b.getProperties());
   }

BUT, when the bus is constructed and hence the AsyncHTTPConduitFactory
constructor is called, the bus has no properties hence the default values
of 5000 and 1000 are used. The setProperties() method is never called again
so I just can't work out how my actual properties get set on the
connection!

Any help much appreciated :-)

Many thanks
Mandy

Sent from a mobile device

Re: Asynchronous http transport keep alive property query

Posted by Daniel Kulp <dk...@apache.org>.
Just logged:
https://issues.apache.org/jira/browse/CXF-5695

for this.   Fairly easy fix which I’m testing now.     Should be committed shortly.

Dan


On Apr 15, 2014, at 3:02 PM, Mandy Warren <ma...@gmail.com> wrote:

> 
> Hi,
> 
> I've knocked up a unit test to prove my settings for
> org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS  and
> org.apache.cxf.transport.http.async.MAX_CONNECTIONS are getting set
> correctly but not having much luck!
> 
> Here's the test:-
> 
>   @Test
>   public void getClientUsingApacheCommonsAsync() throws Exception {
>           BusFactory.getDefaultBus().setProperty
> ("use.async.http.conduit", true);
>           BusFactory.getDefaultBus().setProperty
> ("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS", 10000);
>           BusFactory.getDefaultBus().setProperty
> ("org.apache.cxf.transport.http.async.MAX_CONNECTIONS", 10000);
> 
>           WebClient.create(adfmsDummyServer.getBaseURL(),
>                   Lists.newArrayList(new JacksonJsonProvider()),
> true).path("/delay").accept("application/json").get();
>   // TODO - add some asserts, no idea what yet!
>   }
> 
> I've grep'd the cxf source code and the only place I can see a ref to
> either of the MAX_XXX properties is in AsyncHTTPConduitFactory. An instance
> of this class is constructed when the bus is created and then the method
> setProperties() is called passing in the bus properties to then set on the
> connection:-
> 
>   public AsyncHTTPConduitFactory(Bus b) {
>       this();
>       addListener(b);
>       config.setTcpNoDelay(true);
>       setProperties(b.getProperties());
>   }
> 
> BUT, when the bus is constructed and hence the AsyncHTTPConduitFactory
> constructor is called, the bus has no properties hence the default values
> of 5000 and 1000 are used. The setProperties() method is never called again
> so I just can't work out how my actual properties get set on the
> connection!
> 
> Any help much appreciated :-)
> 
> Many thanks
> Mandy
> 
> Sent from a mobile device

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


Re: Asynchronous http transport keep alive property query

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Mandy

I've found this rather old thread:

http://cxf.547215.n5.nabble.com/Setting-up-keep-alive-timeout-in-client-td558178.html

Not sure if that can be relevant to Async clients. But the properties 
you are setting below seem to be affecting the number of concurrent 
connections...

Cheers, Sergey

On 15/04/14 22:03, Mandy Warren wrote:
> Thanks for the fast reply Sergey! But I am fine with setting the use.async.http.conduit property (your log line proved that :-) ) but the problem I have is with the keep alive settings below.. It doesn't look to me like they are getting set the the values I specify...
>
> Sent from a mobile device
>
>> On 15 Apr 2014, at 21:54, Sergey Beryozkin <sb...@gmail.com> wrote:
>>
>> Hi Mandy
>>
>> In my tests I do
>>
>> WebClient.getConfig(myWebClient),getRequestContext().put("use.async.http.conduit", true);
>>
>> Setting the property on BusFactory.getThreadDefaultBus(true) shpuld also work
>> HTH, Sergey
>>
>>
>>> On 15/04/14 20:02, Mandy Warren wrote:
>>>
>>> Hi,
>>>
>>> I've knocked up a unit test to prove my settings for
>>> org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS  and
>>> org.apache.cxf.transport.http.async.MAX_CONNECTIONS are getting set
>>> correctly but not having much luck!
>>>
>>> Here's the test:-
>>>
>>>     @Test
>>>     public void getClientUsingApacheCommonsAsync() throws Exception {
>>>             BusFactory.getDefaultBus().setProperty
>>> ("use.async.http.conduit", true);
>>>             BusFactory.getDefaultBus().setProperty
>>> ("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS", 10000);
>>>             BusFactory.getDefaultBus().setProperty
>>> ("org.apache.cxf.transport.http.async.MAX_CONNECTIONS", 10000);
>>>
>>>             WebClient.create(adfmsDummyServer.getBaseURL(),
>>>                     Lists.newArrayList(new JacksonJsonProvider()),
>>> true).path("/delay").accept("application/json").get();
>>>     // TODO - add some asserts, no idea what yet!
>>>     }
>>>
>>> I've grep'd the cxf source code and the only place I can see a ref to
>>> either of the MAX_XXX properties is in AsyncHTTPConduitFactory. An instance
>>> of this class is constructed when the bus is created and then the method
>>> setProperties() is called passing in the bus properties to then set on the
>>> connection:-
>>>
>>>     public AsyncHTTPConduitFactory(Bus b) {
>>>         this();
>>>         addListener(b);
>>>         config.setTcpNoDelay(true);
>>>         setProperties(b.getProperties());
>>>     }
>>>
>>> BUT, when the bus is constructed and hence the AsyncHTTPConduitFactory
>>> constructor is called, the bus has no properties hence the default values
>>> of 5000 and 1000 are used. The setProperties() method is never called again
>>> so I just can't work out how my actual properties get set on the
>>> connection!
>>>
>>> Any help much appreciated :-)
>>>
>>> Many thanks
>>> Mandy
>>>
>>> Sent from a mobile device
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com



Re: Asynchronous http transport keep alive property query

Posted by Mandy Warren <ma...@gmail.com>.
Thanks for the fast reply Sergey! But I am fine with setting the use.async.http.conduit property (your log line proved that :-) ) but the problem I have is with the keep alive settings below.. It doesn't look to me like they are getting set the the values I specify...

Sent from a mobile device

> On 15 Apr 2014, at 21:54, Sergey Beryozkin <sb...@gmail.com> wrote:
> 
> Hi Mandy
> 
> In my tests I do
> 
> WebClient.getConfig(myWebClient),getRequestContext().put("use.async.http.conduit", true);
> 
> Setting the property on BusFactory.getThreadDefaultBus(true) shpuld also work
> HTH, Sergey
> 
> 
>> On 15/04/14 20:02, Mandy Warren wrote:
>> 
>> Hi,
>> 
>> I've knocked up a unit test to prove my settings for
>> org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS  and
>> org.apache.cxf.transport.http.async.MAX_CONNECTIONS are getting set
>> correctly but not having much luck!
>> 
>> Here's the test:-
>> 
>>    @Test
>>    public void getClientUsingApacheCommonsAsync() throws Exception {
>>            BusFactory.getDefaultBus().setProperty
>> ("use.async.http.conduit", true);
>>            BusFactory.getDefaultBus().setProperty
>> ("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS", 10000);
>>            BusFactory.getDefaultBus().setProperty
>> ("org.apache.cxf.transport.http.async.MAX_CONNECTIONS", 10000);
>> 
>>            WebClient.create(adfmsDummyServer.getBaseURL(),
>>                    Lists.newArrayList(new JacksonJsonProvider()),
>> true).path("/delay").accept("application/json").get();
>>    // TODO - add some asserts, no idea what yet!
>>    }
>> 
>> I've grep'd the cxf source code and the only place I can see a ref to
>> either of the MAX_XXX properties is in AsyncHTTPConduitFactory. An instance
>> of this class is constructed when the bus is created and then the method
>> setProperties() is called passing in the bus properties to then set on the
>> connection:-
>> 
>>    public AsyncHTTPConduitFactory(Bus b) {
>>        this();
>>        addListener(b);
>>        config.setTcpNoDelay(true);
>>        setProperties(b.getProperties());
>>    }
>> 
>> BUT, when the bus is constructed and hence the AsyncHTTPConduitFactory
>> constructor is called, the bus has no properties hence the default values
>> of 5000 and 1000 are used. The setProperties() method is never called again
>> so I just can't work out how my actual properties get set on the
>> connection!
>> 
>> Any help much appreciated :-)
>> 
>> Many thanks
>> Mandy
>> 
>> Sent from a mobile device
> 
> 
> -- 
> Sergey Beryozkin
> 
> Talend Community Coders
> http://coders.talend.com/
> 
> Blog: http://sberyozkin.blogspot.com

Re: Asynchronous http transport keep alive property query

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Mandy

In my tests I do

WebClient.getConfig(myWebClient),getRequestContext().put("use.async.http.conduit", 
true);

Setting the property on BusFactory.getThreadDefaultBus(true) shpuld also 
work
HTH, Sergey


On 15/04/14 20:02, Mandy Warren wrote:
>
> Hi,
>
> I've knocked up a unit test to prove my settings for
> org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS  and
> org.apache.cxf.transport.http.async.MAX_CONNECTIONS are getting set
> correctly but not having much luck!
>
> Here's the test:-
>
>     @Test
>     public void getClientUsingApacheCommonsAsync() throws Exception {
>             BusFactory.getDefaultBus().setProperty
> ("use.async.http.conduit", true);
>             BusFactory.getDefaultBus().setProperty
> ("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS", 10000);
>             BusFactory.getDefaultBus().setProperty
> ("org.apache.cxf.transport.http.async.MAX_CONNECTIONS", 10000);
>
>             WebClient.create(adfmsDummyServer.getBaseURL(),
>                     Lists.newArrayList(new JacksonJsonProvider()),
> true).path("/delay").accept("application/json").get();
>     // TODO - add some asserts, no idea what yet!
>     }
>
> I've grep'd the cxf source code and the only place I can see a ref to
> either of the MAX_XXX properties is in AsyncHTTPConduitFactory. An instance
> of this class is constructed when the bus is created and then the method
> setProperties() is called passing in the bus properties to then set on the
> connection:-
>
>     public AsyncHTTPConduitFactory(Bus b) {
>         this();
>         addListener(b);
>         config.setTcpNoDelay(true);
>         setProperties(b.getProperties());
>     }
>
> BUT, when the bus is constructed and hence the AsyncHTTPConduitFactory
> constructor is called, the bus has no properties hence the default values
> of 5000 and 1000 are used. The setProperties() method is never called again
> so I just can't work out how my actual properties get set on the
> connection!
>
> Any help much appreciated :-)
>
> Many thanks
> Mandy
>
> Sent from a mobile device
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com