Hi Andrei

I do expect such a builder-style code be thread safe, however if it is very intensive then you might want to finalize the call with a myWebClient.reset() which will clean the thread local state more proactively,

The client factor bean also has a timeToKeepState property but at the moment this property is not available at the schema level but having an explicit reset() would be the most effective option

Thanks, Sergey


On 08/06/17 09:13, Andrei Shakirin wrote:
Hi,

Is that code thread and memory leak safe (by intensive multithread using):

<jaxrs-client:client id="myWebClient"
                   address="http://localhost/myservice";
                   serviceClass="org.apache.cxf.jaxrs.client.WebClient"
                   inheritHeaders="true"
                   threadSafe="true">

         <jaxrs-client:providers>
             <bean 
class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>
         </jaxrs-client:providers>

         <jaxrs-client:properties>
             <entry key="http.receive.timeout" value="60"/>
         </jaxrs-client:properties>
</jaxrs-client:client>

....
    // injection on class level
    WebClient myWebClient;

     // concurrent using
     Response myResponse = myWebClient.accept(MediaType.APPLICATION_JSON)
                         .header("Content-Type", MediaType.APPLICATION_JSON)
                         .query(QUERY_TOKEN, apiToken)
                         .path(PATH_SERVICE_AREAS + zipCode)
                         .get();
       myWebClient.reset()

Regards,
Andrei.

Reply via email to