Quantcast

FailoverTargetSelector and Thread Safety...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

FailoverTargetSelector and Thread Safety...

James Carman
I am probably misunderstanding something here, but in the Javadocs for
FailoverTargetSelector it says:

"Note that this feature changes the conduit on the fly and thus makes the
Client not thread safe."

In the documentation (http://cxf.apache.org/docs/jax-rs-failover.html), it
shows this setup:

<bean id="myWebClient"
class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean"
factory-method="createWebClient">
  <property name="address" value="http://some.base.url.that.responds/" />
  <property name="features">
    <ref bean="failover1"/>
  </property>
</bean>

Does that mean that the "myWebClient" bean not be thread-safe at that point?

Thanks,

James
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FailoverTargetSelector and Thread Safety...

Sergey Beryozkin
Administrator
Hi James

It depends where it is injected to - if it is collected by the main()
initiated flow then it will still be OK.

I guess the problems might occur if such clients are expected to
fail-over while running in scope of the server flow.

Though I'm not sure how critical it is for a client to fail-over in the
context of the server flow (the failover might be be costly in such
cases if there's a delay between retries, etc).

That said, may be some synchronization can be applied at the
FailovertargetSelector to support such cases.

Thanks, Sergey


On 02/05/17 17:54, James Carman wrote:

> I am probably misunderstanding something here, but in the Javadocs for
> FailoverTargetSelector it says:
>
> "Note that this feature changes the conduit on the fly and thus makes the
> Client not thread safe."
>
> In the documentation (http://cxf.apache.org/docs/jax-rs-failover.html), it
> shows this setup:
>
> <bean id="myWebClient"
> class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean"
> factory-method="createWebClient">
>   <property name="address" value="http://some.base.url.that.responds/" />
>   <property name="features">
>     <ref bean="failover1"/>
>   </property>
> </bean>
>
> Does that mean that the "myWebClient" bean not be thread-safe at that point?
>
> Thanks,
>
> James
>

Loading...