cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: CXF JAXRS Client : HttpAsyncClient and KeepAlive
Date Mon, 18 Apr 2016 09:06:00 GMT
Hi Andrei

Many thanks, perhaps a combination of properties needs to be set,

http://cxf.apache.org/docs/asynchronous-client-http-transport.html

suggests CONNECTION_TTL is related to keeping the connection alive, but 
there's also a KEEP_ALIVE property. There must be some recommendations 
on HTTP client forums for it...

Cheers, Sergey

On 17/04/16 11:28, Andrei Shakirin wrote:
> Hi,
>
> My understanding of org.apache.cxf.transport.http.async.CONNECTION_TTL is time to life
in the connection pool (PoolingNHttpClientConnectionManager.CPool).
> By next try of getting connection entry from the pool,  it is either expired (if time
exceed CONNECTION_TTL) and must be re-established or can be reused.
> So I expect that the connection wouldn't be re-established automatically, when CONNECTION_TTL
is exceed, but wouldn't be reused from the pool by next try.
> Am I missing something?
>
> Regards,
> Andrei.
>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Freitag, 15. April 2016 11:28
>> To: users@cxf.apache.org
>> Subject: Re: CXF JAXRS Client : HttpAsyncClient and KeepAlive
>>
>> Hi
>>
>> Looks like I got confused. it is all about Keep Alive while I somehow got
>> assumed that it was about not timing out (though, checking the thread I see I
>> was not confused at the start of it :-)).
>>
>> I don't know why AsyncConduit is not reacting as expected in this case.
>> This needs to be investigated but unfortunately I've no time for it.
>>
>> May be you can dig a bit deeper, example, can you check if setting those
>> properties when using HttpClient directly is effective ?
>>
>> Cheers, Sergey
>> On 15/04/16 03:05, Viral Gohel wrote:
>>> Hi Sergey,
>>>
>>> About the issue marked as 'Not a problem',
>>> https://issues.apache.org/jira/browse/CXF-6846
>>> <https://issues.apache.org/jira/browse/CXF-6846>  , this is the
>>> original test case that i checked with,
>>>
>>> /**
>>>    * @author Viral Gohel
>>>    *
>>>    */
>>> public class TestAsyncTTL extends Assert {
>>> 	private Logger logger=LoggerFactory.getLogger(TestAsyncTTL.class);
>>> //
>>> 	private static WebServiceContext context;
>>> 	@BeforeClass
>>> 	public static void prepareEndpoint() throws InterruptedException {
>>> 		Bus bus = BusFactory.getThreadDefaultBus();
>>> 		bus.setProperty(AsyncHTTPConduit.USE_ASYNC,
>>> AsyncHTTPConduitFactory.UseAsyncPolicy.ALWAYS);
>>>
>> 	bus.setProperty(AsyncHTTPConduitFactory.CONNECTION_TTL,1);
>>> 		bus.setProperty(AsyncHTTPConduitFactory.SO_TIMEOUT, 5);
>>>
>> 	bus.setProperty(AsyncHTTPConduitFactory.SO_KEEPALIVE,Boolean.
>> TRUE);
>>> 		bus.getInInterceptors().add(new LoggingInInterceptor());
>>> 		bus.getOutInterceptors().add(new
>> LoggingOutInterceptor());
>>> 		BusFactory.setThreadDefaultBus(bus);
>>> 		AsyncHTTPConduitFactory hcf =
>>> (AsyncHTTPConduitFactory)bus.getExtension(HTTPConduitFactory.class);
>>> 		Endpoint endpoint =
>>> Endpoint.publish("http://localhost:8123/testService",
>>> new GreeterService() {
>>>
>>>
>>> 			public String sayHello(long cnt) throws
>> InterruptedException {
>>> 				     Thread.sleep(70000);
>>> 	                 return "Hello, finally! " + cnt;
>>> 			}
>>> 		});
>>>
>>> 	}
>>> 	@Test
>>> 	public void testService() throws InterruptedException {
>>>
>>>
>>> 		/*HTTPClientPolicy clientPolicy=new HTTPClientPolicy();
>>> 		clientPolicy.setAllowChunking(false);
>>> 		clientPolicy.setConnection(ConnectionType.KEEP_ALIVE);
>>> */
>>> 		//ogger.debug("Receive Timout is : " +
>>> clientPolicy.getReceiveTimeout());
>>>
>>> 		ClientProxyFactoryBean bean = new
>> ClientProxyFactoryBean();
>>> 		//bean.setBus(bus);
>>> 		bean.setAddress("http://localhost:8123/testService");
>>> 		bean.setServiceClass(GreeterService.class);
>>> 		GreeterService service = (GreeterService) bean.create();
>>> 		AsyncHTTPConduit conduit = (AsyncHTTPConduit)
>>> ClientProxy.getClient(service).getConduit();
>>> 		//conduit.setClient(clientPolicy);
>>>
>>> 		service.sayHello(5);
>>> 		//Thread.sleep(5000);
>>> 	}
>>> }
>>>
>>> CONNECTION_TTL seems to be related to Http Keep-Alive, while
>>> ReceiveTimeout with Sockets.
>>>
>>> So, with the above test case, i would expect that the Http connection
>>> should be re-established, after 1 ms.
>>>
>>> Please suggest.
>>>
>>> Regards,
>>> Viral Gohel
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://cxf.547215.n5.nabble.com/CXF-JAXRS-Client-HttpAsyncClient-and-K
>>> eepAlive-tp5747402p5767875.html Sent from the cxf-user mailing list
>>> archive at Nabble.com.
>>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/


-- 
Sergey Beryozkin

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

Mime
View raw message