You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by James Carman <ja...@carmanconsulting.com> on 2017/05/02 16:54:01 UTC

FailoverTargetSelector and Thread Safety...

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

Re: FailoverTargetSelector and Thread Safety...

Posted by Sergey Beryozkin <sb...@gmail.com>.
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
>