cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > JAX-RS Failover
Date Thu, 16 Jun 2011 10:19:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Failover">JAX-RS
Failover</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~sergey_beryozkin">Sergey
Beryozkin</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{span:style=font-size:2em;font-weight:bold}
JAX-RS: Failover {span} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{toc}
<br> <br>Starting from CXF 2.4.1, CXF JAX-RS clients can be configured for them
to become failover-capable. <br>Core CXF Failover and Load Distribution features are
supported. <br> <br> <br>h1. Failover <br> <br>Proxies and WebClients
can be configured to failover to alternate addresses in case of connection-related failures.
<br>Sequential and Random strategies are supported and implementers can build more sophisticated
failover features by retrieving <br>alternate addresses from locators and other intermediaries.
<br> <br>h2. Spring  <br> <br>{code:xml} <br> <br>&lt;beans
xmlns=&quot;http://www.springframework.org/schema/beans&quot; <br>       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
<br>       xmlns:jaxrs=&quot;http://cxf.apache.org/jaxrs&quot; <br>  
    xmlns:util=&quot;http://www.springframework.org/schema/util&quot; <br> 
     xsi:schemaLocation=&quot; <br>http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
<br>http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
<br>http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd&quot;&gt;
<br>    &lt;bean class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;/&gt;
<br> <br>    &lt;util:list id=&quot;addressList&quot;&gt; <br>
       &lt;value&gt;http://localhost:${testutil.ports.Server.1}/rest&lt;/value&gt;
<br>        &lt;value&gt;http://localhost:${testutil.ports.Server.2}/rest&lt;/value&gt;
<br>        &lt;value&gt;http://localhost:${testutil.ports.Server.3}/rest&lt;/value&gt;
<br>    &lt;/util:list&gt; <br> <br>    &lt;bean id=&quot;SequentialAddresses&quot;
class=&quot;org.apache.cxf.clustering.SequentialStrategy&quot;&gt; <br>
       &lt;property name=&quot;alternateAddresses&quot;&gt; <br>   
        &lt;ref bean=&quot;addressList&quot;/&gt; <br>        &lt;/property&gt;
<br>    &lt;/bean&gt; <br> <br>    &lt;bean id=&quot;RandomAddresses&quot;
class=&quot;org.apache.cxf.clustering.RandomStrategy&quot;&gt; <br>    
   &lt;property name=&quot;alternateAddresses&quot;&gt; <br>       
    &lt;ref bean=&quot;addressList&quot;/&gt; <br>        &lt;/property&gt;
<br>    &lt;/bean&gt; <br> <br>    &lt;bean id=&quot;failover1&quot;
class=&quot;org.apache.cxf.jaxrs.features.clustering.FailoverFeature&quot;&gt;
<br>        &lt;property name=&quot;strategy&quot; ref=&quot;SequentialAddresses&quot;/&gt;
<br>    &lt;/bean&gt; <br> <br>    &lt;bean id=&quot;failover2&quot;
class=&quot;org.apache.cxf.jaxrs.features.clustering.FailoverFeature&quot;&gt;
<br>        &lt;property name=&quot;strategy&quot; ref=&quot;RandomAddresses&quot;/&gt;
<br>    &lt;/bean&gt; <br> <br>    &lt;jaxrs:client id=&quot;failoverSequential&quot;
address=&quot;http://localhost:8080/initialAddress&quot;&gt; <br>      
&lt;jaxrs:features&gt; <br>           &lt;ref bean=&quot;failover1&quot;/&gt;
<br>       &lt;/jaxrs:features&gt; <br>    &lt;/jaxrs:client&gt;
<br> <br>    &lt;jaxrs:client id=&quot;failoverRandom&quot; address=&quot;http://localhost:8080/initialAddress&quot;&gt;
<br>       &lt;jaxrs:features&gt; <br>           &lt;ref bean=&quot;failover2&quot;/&gt;
<br>       &lt;/jaxrs:features&gt; <br>    &lt;/jaxrs:client&gt;
<br> <br>    &lt;bean id=&quot;myWebClient&quot; class=&quot;org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean&quot;
 <br>factory-method=&quot;createWebClient&quot;&gt;  <br>        &lt;property
name=&quot;address&quot; value=&quot;http://some.base.url.that.responds/&quot;
/&gt;  <br>        &lt;property name=&quot;features&quot;&gt; <br>
            &lt;util:list&gt; <br>                &lt;ref bean=&quot;failover1&quot;/&gt;
 <br>             &lt;/util:list&gt; <br>        &lt;/property&gt;
  <br>    &lt;/bean&gt;  <br>&lt;/beans&gt; <br>{code} <br>
<br>Note that failover feature for jaxrs:client gets configured nearly exactly the same
way as it&#39;s done for JAX-WS clients. The difference at this stage is that feature
class name (org.apache.cxf.jaxrs.features.clustering.FailoverFeature) and a &#39;strategy&#39;
property are &#39;hidden&#39; for JAX-WS clients due to the use of Spring handlers,
example: <br>{code:xml} <br>&lt;jaxws:client name=&quot;{http://cxf.apache.org/greeter_control}ReplicatedPortA&quot;
<br>                  createdFromAPI=&quot;true&quot;&gt; <br>   
    &lt;jaxws:features&gt; <br>            &lt;clustering:failover&gt;
<br>                &lt;clustering:strategy&gt; <br>                 
  &lt;ref bean=&quot;SequentialAddresses&quot;/&gt; <br>           
    &lt;/clustering:strategy&gt; <br>            &lt;/clustering:failover&gt;
<br>        &lt;/jaxws:features&gt; <br>    &lt;/jaxws:client&gt;
<br>{code}   <br> <br>In other words, JAX-RS clients can not use clustering:failover/clustering:strategy
only at this stage, the rest the same. An efoort will be undertaken to make sure this configuration
becomes identical for JAX-WS and JAX-RS clients.  <br> <br>h2. Code <br>
<br>{code:java} <br>org.apache.cxf.jaxrs.features.clustering.FailoverFeature feature
=  <br>    new org.apache.cxf.jaxrs.features.clustering.FailoverFeature(); <br>List&lt;String&gt;
alternateAddresses = new ArrayList&lt;String&gt;(); <br>// addresses are alternate
addresses provided at start-up <br>for (String s : address) { <br>    alternateAddresses.add(s);
<br>} <br>SequentialStrategy strategy = new SequentialStrategy(); <br>strategy.setAlternateAddresses(alternateAddresses);
<br>feature.setStrategy(strategy); <br> <br>JAXRSClientFactoryBean bean
= new JAXRSClientFactoryBean(); <br>bean.setAddress(&quot;http://localhost:8080/inactive-replica&quot;);
<br>List&lt;AbstractFeature&gt; features = new ArrayList&lt;AbstractFeature&gt;();
<br>features.add(feature); <br>bean.setFeatures(features); <br> <br>//
create proxy: <br>bean.create(BookStore.class); <br>// create web client <br>bean.createWebClient();
<br>{code} <br> <br>h1. Load Distribution  <br> <br>CXF Load
Distribution feature is a failover feature which can iterate where alternate addresses not
only in case of failures but also after a successful invocation has been done. <br>It
is configured for CXF JAX-RS clients exactly the same way Failover feature is configured,
the only difference that a (conduit) selector property is also specified, example: <br>{code:xml}
<br>&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
<br>       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; <br>
      xmlns:jaxrs=&quot;http://cxf.apache.org/jaxrs&quot; <br>       xmlns:util=&quot;http://www.springframework.org/schema/util&quot;
<br>       xsi:schemaLocation=&quot; <br>http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
<br>http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
<br>http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd&quot;&gt;
<br>    &lt;bean class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;/&gt;
<br> <br>    &lt;util:list id=&quot;addressList&quot;&gt; <br>
       &lt;value&gt;http://localhost:${testutil.ports.Server.1}/rest&lt;/value&gt;
<br>        &lt;value&gt;http://localhost:${testutil.ports.Server.2}/rest&lt;/value&gt;
<br>        &lt;value&gt;http://localhost:${testutil.ports.Server.3}/rest&lt;/value&gt;
<br>    &lt;/util:list&gt; <br> <br>    &lt;bean id=&quot;SequentialAddresses&quot;
class=&quot;org.apache.cxf.clustering.SequentialStrategy&quot;&gt; <br>
       &lt;property name=&quot;alternateAddresses&quot;&gt; <br>   
        &lt;ref bean=&quot;addressList&quot;/&gt; <br>        &lt;/property&gt;
<br>    &lt;/bean&gt; <br> <br>    &lt;bean id=&quot;targetSelector&quot;
class=&quot;org.apache.cxf.clustering.LoadDistributorTargetSelector&quot;/&gt;
<br> <br>    &lt;jaxrs:client id=&quot;loadDistributionSequential&quot;
address=&quot;http://localhost:8080/initialAddress&quot;&gt; <br>      
&lt;jaxrs:features&gt; <br>           &lt;bean class=&quot;org.apache.cxf.jaxrs.features.clustering.FailoverFeature&quot;&gt;
<br>              &lt;property name=&quot;strategy&quot; ref=&quot;SequentialAddresses&quot;/&gt;
<br>              &lt;property name=&quot;selector&quot; ref=&quot;targetSelector&quot;/&gt;
  <br>           &lt;/bean&gt; <br>       &lt;/jaxrs:features&gt;
<br>    &lt;/jaxrs:client&gt; <br>{code}  <br> <br>the selector
can be set from code like this: <br>{code:java} <br>org.apache.cxf.jaxrs.features.clustering.FailoverFeature
feature =  <br>    new org.apache.cxf.jaxrs.features.clustering.FailoverFeature(); <br>feature.setSelector(new
org.apache.cxf.clustering.LoadDistributorTargetSelector()); <br>{code}  <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p><span style="font-size:2em;font-weight:bold"> JAX-RS: Failover </span></p>

<div>
<ul>
    <li><a href='#JAX-RSFailover-Failover'>Failover</a></li>
<ul>
    <li><a href='#JAX-RSFailover-Spring'>Spring</a></li>
    <li><a href='#JAX-RSFailover-Code'>Code</a></li>
</ul>
    <li><a href='#JAX-RSFailover-LoadDistribution'>Load Distribution</a></li>
</ul></div>

<p>Starting from CXF 2.4.1, CXF JAX-RS clients can be configured for them to become
failover-capable.<br/>
Core CXF Failover and Load Distribution features are supported.</p>


<h1><a name="JAX-RSFailover-Failover"></a>Failover</h1>

<p>Proxies and WebClients can be configured to failover to alternate addresses in case
of connection-related failures.<br/>
Sequential and Random strategies are supported and implementers can build more sophisticated
failover features by retrieving<br/>
alternate addresses from locators and other intermediaries.</p>

<h2><a name="JAX-RSFailover-Spring"></a>Spring </h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">

&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       <span class="code-keyword">xmlns:jaxrs</span>=<span class="code-quote">"http://cxf.apache.org/jaxrs"</span>
       <span class="code-keyword">xmlns:util</span>=<span class="code-quote">"http://www.springframework.org/schema/util"</span>
       xsi:schemaLocation="
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"</span>/&gt;</span>
    
    <span class="code-tag">&lt;util:list id=<span class="code-quote">"addressList"</span>&gt;</span>
        <span class="code-tag">&lt;value&gt;</span>http://localhost:${testutil.ports.Server.1}/rest<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;value&gt;</span>http://localhost:${testutil.ports.Server.2}/rest<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;value&gt;</span>http://localhost:${testutil.ports.Server.3}/rest<span
class="code-tag">&lt;/value&gt;</span>
    <span class="code-tag">&lt;/util:list&gt;</span>

    <span class="code-tag">&lt;bean id=<span class="code-quote">"SequentialAddresses"</span>
class=<span class="code-quote">"org.apache.cxf.clustering.SequentialStrategy"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"alternateAddresses"</span>&gt;</span>
            <span class="code-tag">&lt;ref bean=<span class="code-quote">"addressList"</span>/&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>

    <span class="code-tag">&lt;bean id=<span class="code-quote">"RandomAddresses"</span>
class=<span class="code-quote">"org.apache.cxf.clustering.RandomStrategy"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"alternateAddresses"</span>&gt;</span>
            <span class="code-tag">&lt;ref bean=<span class="code-quote">"addressList"</span>/&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>

    <span class="code-tag">&lt;bean id=<span class="code-quote">"failover1"</span>
class=<span class="code-quote">"org.apache.cxf.jaxrs.features.clustering.FailoverFeature"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"strategy"</span>
ref=<span class="code-quote">"SequentialAddresses"</span>/&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>

    <span class="code-tag">&lt;bean id=<span class="code-quote">"failover2"</span>
class=<span class="code-quote">"org.apache.cxf.jaxrs.features.clustering.FailoverFeature"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"strategy"</span>
ref=<span class="code-quote">"RandomAddresses"</span>/&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>

    <span class="code-tag">&lt;jaxrs:client id=<span class="code-quote">"failoverSequential"</span>
address=<span class="code-quote">"http://localhost:8080/initialAddress"</span>&gt;</span>
       <span class="code-tag">&lt;jaxrs:features&gt;</span>
           <span class="code-tag">&lt;ref bean=<span class="code-quote">"failover1"</span>/&gt;</span>
       <span class="code-tag">&lt;/jaxrs:features&gt;</span>
    <span class="code-tag">&lt;/jaxrs:client&gt;</span>

    <span class="code-tag">&lt;jaxrs:client id=<span class="code-quote">"failoverRandom"</span>
address=<span class="code-quote">"http://localhost:8080/initialAddress"</span>&gt;</span>
       <span class="code-tag">&lt;jaxrs:features&gt;</span>
           <span class="code-tag">&lt;ref bean=<span class="code-quote">"failover2"</span>/&gt;</span>
       <span class="code-tag">&lt;/jaxrs:features&gt;</span>
    <span class="code-tag">&lt;/jaxrs:client&gt;</span>

    &lt;bean id=<span class="code-quote">"myWebClient"</span> class=<span
class="code-quote">"org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean"</span> 
factory-method=<span class="code-quote">"createWebClient"</span>&gt; 
        <span class="code-tag">&lt;property name=<span class="code-quote">"address"</span>
value=<span class="code-quote">"http://some.base.url.that.responds/"</span> /&gt;</span>

        <span class="code-tag">&lt;property name=<span class="code-quote">"features"</span>&gt;</span>
             <span class="code-tag">&lt;util:list&gt;</span>
                <span class="code-tag">&lt;ref bean=<span class="code-quote">"failover1"</span>/&gt;</span>

             <span class="code-tag">&lt;/util:list&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>  
    <span class="code-tag">&lt;/bean&gt;</span> 
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<p>Note that failover feature for jaxrs:client gets configured nearly exactly the same
way as it's done for JAX-WS clients. The difference at this stage is that feature class name
(org.apache.cxf.jaxrs.features.clustering.FailoverFeature) and a 'strategy' property are 'hidden'
for JAX-WS clients due to the use of Spring handlers, example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;jaxws:client name=<span class="code-quote">"{http://cxf.apache.org/greeter_control}ReplicatedPortA"</span>
                  createdFromAPI=<span class="code-quote">"true"</span>&gt;
        <span class="code-tag">&lt;jaxws:features&gt;</span>
            <span class="code-tag">&lt;clustering:failover&gt;</span>
                <span class="code-tag">&lt;clustering:strategy&gt;</span>
                    <span class="code-tag">&lt;ref bean=<span class="code-quote">"SequentialAddresses"</span>/&gt;</span>
                <span class="code-tag">&lt;/clustering:strategy&gt;</span>
            <span class="code-tag">&lt;/clustering:failover&gt;</span>
        <span class="code-tag">&lt;/jaxws:features&gt;</span>
    <span class="code-tag">&lt;/jaxws:client&gt;</span>
</pre>
</div></div>  

<p>In other words, JAX-RS clients can not use clustering:failover/clustering:strategy
only at this stage, the rest the same. An efoort will be undertaken to make sure this configuration
becomes identical for JAX-WS and JAX-RS clients. </p>

<h2><a name="JAX-RSFailover-Code"></a>Code</h2>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
org.apache.cxf.jaxrs.features.clustering.FailoverFeature feature = 
    <span class="code-keyword">new</span> org.apache.cxf.jaxrs.features.clustering.FailoverFeature();
List&lt;<span class="code-object">String</span>&gt; alternateAddresses
= <span class="code-keyword">new</span> ArrayList&lt;<span class="code-object">String</span>&gt;();
<span class="code-comment">// addresses are alternate addresses provided at start-up
</span><span class="code-keyword">for</span> (<span class="code-object">String</span>
s : address) {
    alternateAddresses.add(s);
}
SequentialStrategy strategy = <span class="code-keyword">new</span> SequentialStrategy();
strategy.setAlternateAddresses(alternateAddresses);
feature.setStrategy(strategy);

JAXRSClientFactoryBean bean = <span class="code-keyword">new</span> JAXRSClientFactoryBean();
bean.setAddress(<span class="code-quote">"http:<span class="code-comment">//localhost:8080/inactive-replica"</span>);
</span>List&lt;AbstractFeature&gt; features = <span class="code-keyword">new</span>
ArrayList&lt;AbstractFeature&gt;();
features.add(feature);
bean.setFeatures(features);

<span class="code-comment">// create proxy:
</span>bean.create(BookStore.class);
<span class="code-comment">// create web client
</span>bean.createWebClient();
</pre>
</div></div>

<h1><a name="JAX-RSFailover-LoadDistribution"></a>Load Distribution </h1>

<p>CXF Load Distribution feature is a failover feature which can iterate where alternate
addresses not only in case of failures but also after a successful invocation has been done.<br/>
It is configured for CXF JAX-RS clients exactly the same way Failover feature is configured,
the only difference that a (conduit) selector property is also specified, example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       <span class="code-keyword">xmlns:jaxrs</span>=<span class="code-quote">"http://cxf.apache.org/jaxrs"</span>
       <span class="code-keyword">xmlns:util</span>=<span class="code-quote">"http://www.springframework.org/schema/util"</span>
       xsi:schemaLocation="
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"</span>/&gt;</span>
    
    <span class="code-tag">&lt;util:list id=<span class="code-quote">"addressList"</span>&gt;</span>
        <span class="code-tag">&lt;value&gt;</span>http://localhost:${testutil.ports.Server.1}/rest<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;value&gt;</span>http://localhost:${testutil.ports.Server.2}/rest<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;value&gt;</span>http://localhost:${testutil.ports.Server.3}/rest<span
class="code-tag">&lt;/value&gt;</span>
    <span class="code-tag">&lt;/util:list&gt;</span>

    <span class="code-tag">&lt;bean id=<span class="code-quote">"SequentialAddresses"</span>
class=<span class="code-quote">"org.apache.cxf.clustering.SequentialStrategy"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"alternateAddresses"</span>&gt;</span>
            <span class="code-tag">&lt;ref bean=<span class="code-quote">"addressList"</span>/&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>

    <span class="code-tag">&lt;bean id=<span class="code-quote">"targetSelector"</span>
class=<span class="code-quote">"org.apache.cxf.clustering.LoadDistributorTargetSelector"</span>/&gt;</span>

    <span class="code-tag">&lt;jaxrs:client id=<span class="code-quote">"loadDistributionSequential"</span>
address=<span class="code-quote">"http://localhost:8080/initialAddress"</span>&gt;</span>
       <span class="code-tag">&lt;jaxrs:features&gt;</span>
           <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.jaxrs.features.clustering.FailoverFeature"</span>&gt;</span>
              <span class="code-tag">&lt;property name=<span class="code-quote">"strategy"</span>
ref=<span class="code-quote">"SequentialAddresses"</span>/&gt;</span>
              <span class="code-tag">&lt;property name=<span class="code-quote">"selector"</span>
ref=<span class="code-quote">"targetSelector"</span>/&gt;</span>  
           <span class="code-tag">&lt;/bean&gt;</span>
       <span class="code-tag">&lt;/jaxrs:features&gt;</span>
    <span class="code-tag">&lt;/jaxrs:client&gt;</span>
</pre>
</div></div> 

<p>the selector can be set from code like this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
org.apache.cxf.jaxrs.features.clustering.FailoverFeature feature = 
    <span class="code-keyword">new</span> org.apache.cxf.jaxrs.features.clustering.FailoverFeature();
feature.setSelector(<span class="code-keyword">new</span> org.apache.cxf.clustering.LoadDistributorTargetSelector());
</pre>
</div></div> 
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Failover">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=26805872&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Failover?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message