Thanks and it is working
-----Original Message-----
From: Andrei Shakirin <[email protected]>
Sent: Sunday, 5 August 2018 10:04 PM
To: [email protected]; [email protected]
Subject: RE: How could I set HttpClientPolicy per request?
Hi,
I think it should work this way:
((BindingProvider)proxy).getRequestContext().put("thread.local.request.conte
xt", "true");
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setAccept("text/xml");
httpClientPolicy.setAcceptEncoding("gzip,deflate,sdch");
httpClientPolicy.setCacheControl("No-Cache");
httpClientPolicy.setContentType("text/xml");
httpClientPolicy.setConnectionTimeout(2000);
httpClientPolicy.setReceiveTimeout(receiveTimeout);
((BindingProvider)proxy).getRequestContext().put(HTTPClientPolicy.class.getN
ame(), httpClientPolicy);
The code should works concurrently per request.
Regards,
Andrei.
> -----Original Message-----
> From: Christopher Cheng [mailto:[email protected]] On Behalf Of
> [email protected]
> Sent: Donnerstag, 26. Juli 2018 03:00
> To: [email protected]
> Subject: How could I set HttpClientPolicy per request?
>
> I have an user requirement to set timeout per request such that the
> user can specify the timeout for the web service.
>
>
>
>
>
>
>
> Client client = ClientProxy.getClient(port);
>
> client.getRequestContext().put("thread.local.request.context",
> "true");
>
>
>
> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>
> httpClientPolicy.setAllowChunking(false);
>
> httpClientPolicy.setAccept("text/xml");
>
> httpClientPolicy.setAcceptEncoding("gzip,deflate,sdch");
>
> httpClientPolicy.setCacheControl("No-Cache");
>
> httpClientPolicy.setContentType("text/xml");
>
> httpClientPolicy.setConnectionTimeout(2000);
>
> httpClientPolicy.setReceiveTimeout(receiveTimeout);
>
>
>
> HTTPConduit http = (HTTPConduit) client.getConduit();
>
> http.setClient(httpClientPolicy);
>
>
>
>
>
>
>
> receiveTimeout above is a parameter. I found out that if the port is a
> static variable (shared by all threads), then after the first user set
> receiveTimeout, the 2nd user will be affected by this setting.
>
> What I want to achieve is that if the user does not set the
> receiveTimeout, it will be using CXF default which is 60s and it will be
affected by other threads.
>
>
As a recipient of an email from Talend, your contact personal data will be
on our systems. Please see our contacts privacy notice at Talend, Inc.
<https://www.talend.com/contacts-privacy-policy/>