Search in sources :

Example 16 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project camel by apache.

the class FailOverFeatureTest method startRoute.

private void startRoute(DefaultCamelContext ctx, final String proxy, final String real) throws Exception {
    ctx.addRoutes(new RouteBuilder() {

        public void configure() {
            String alt = SERVICE_ADDRESS;
            List<String> serviceList = new ArrayList<String>();
            serviceList.add(alt);
            RandomStrategy strategy = new RandomStrategy();
            strategy.setAlternateAddresses(serviceList);
            FailoverFeature ff = new FailoverFeature();
            ff.setStrategy(strategy);
            CxfEndpoint endpoint = (CxfEndpoint) (endpoint(real));
            endpoint.getFeatures().add(ff);
            from(proxy).to(endpoint);
        }
    });
    ctx.start();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) RandomStrategy(org.apache.cxf.clustering.RandomStrategy) FailoverFeature(org.apache.cxf.clustering.FailoverFeature) List(java.util.List) ArrayList(java.util.ArrayList)

Example 17 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project jbossws-cxf by jbossws.

the class CXFClientClusterTestCase method testCluster.

@Test
@RunAsClient
public void testCluster() throws Exception {
    List<String> serviceList = new ArrayList<String>();
    serviceList.add(baseURL.toExternalForm() + "/ClusetrService");
    RandomStrategy strategy = new RandomStrategy();
    strategy.setAlternateAddresses(serviceList);
    FailoverFeature ff = new FailoverFeature();
    ff.setStrategy(strategy);
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setAddress("http://localhost:8080/notExist/NotExistPort");
    factory.getFeatures().add(ff);
    factory.setServiceClass(Endpoint.class);
    Endpoint proxy = factory.create(Endpoint.class);
    assertEquals("Unexpected resposne", "cluster", proxy.echo("cluster"));
    URL wsdlURL = new URL(baseURL.toExternalForm() + "/ClusetrService?wsdl");
    QName qname = new QName("http://org.jboss.ws/jaxws/cxf/endpoint", "EndpointService");
    Service service = Service.create(wsdlURL, qname);
    Endpoint endpoint = service.getPort(Endpoint.class, ff);
    ((BindingProvider) endpoint).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/notExist/NotExistPort");
    assertEquals("Unexpected resposne", "cluster", endpoint.echo("cluster"));
}
Also used : RandomStrategy(org.apache.cxf.clustering.RandomStrategy) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) FailoverFeature(org.apache.cxf.clustering.FailoverFeature) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 18 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class AbstractFailoverTest method testSequentialStrategyWith406NoFailover.

@Test
public void testSequentialStrategyWith406NoFailover() throws Exception {
    FailoverFeature feature = getFeature(false, Server.ADDRESS3);
    strategyTestWebClientHttpError(Server.ADDRESS2, feature, Server.ADDRESS3, true);
}
Also used : FailoverFeature(org.apache.cxf.clustering.FailoverFeature) Test(org.junit.Test)

Example 19 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class AbstractFailoverTest method testSequentialStrategyWithDiffBaseAddresses2.

@Test
public void testSequentialStrategyWithDiffBaseAddresses2() throws Exception {
    FailoverFeature feature = getFeature(false, Server.ADDRESS3, null);
    strategyTest(Server.ADDRESS1, feature, Server.ADDRESS3, Server.ADDRESS2, false, false, true);
}
Also used : FailoverFeature(org.apache.cxf.clustering.FailoverFeature) Test(org.junit.Test)

Example 20 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class AbstractFailoverTest method testSequentialStrategyWebClient.

@Test
public void testSequentialStrategyWebClient() throws Exception {
    FailoverFeature feature = getFeature(false, Server.ADDRESS2, Server.ADDRESS3);
    strategyTestWebClient(Server.ADDRESS1, feature, Server.ADDRESS2, null, false, false);
}
Also used : FailoverFeature(org.apache.cxf.clustering.FailoverFeature) Test(org.junit.Test)

Aggregations

FailoverFeature (org.apache.cxf.clustering.FailoverFeature)29 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)7 CircuitBreakerFailoverFeature (org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature)7 RandomStrategy (org.apache.cxf.clustering.RandomStrategy)4 SequentialStrategy (org.apache.cxf.clustering.SequentialStrategy)4 WebClient (org.apache.cxf.jaxrs.client.WebClient)4 ProcessingException (javax.ws.rs.ProcessingException)3 Book (org.apache.cxf.systest.jaxrs.Book)3 BookStore (org.apache.cxf.systest.jaxrs.BookStore)3 URL (java.net.URL)2 RetryStrategy (org.apache.cxf.clustering.RetryStrategy)2 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)2 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)2 IOException (java.io.IOException)1 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1