Search code examples
springsoapcxf

CXF RetryStrategy not working for Soap Webservice


I'm using CXF for a SOAP webservice client and somehow, I'm unable to get a working RetryStrategy as a FailoverFeature. Another LoggingFeature is working fine. This is my Spring configuration:

@Bean
public MyPort myPort() {
    final RetryStrategy retryStrategy = new RetryStrategy();
    retryStrategy.setMaxNumberOfRetries(5);
    retryStrategy.setDelayBetweenRetries(3000);
    FailoverFeature failoverFeature = new FailoverFeature();
    failoverFeature.setStrategy(retryStrategy);
    failoverFeature.setTargetSelector(new FailoverTargetSelector(endpointAddress));

    final LoggingFeature logFeature = new LoggingFeature();
    MyService service = new MyService(WSDL_LOCATION, logFeature, failoverFeature);
    MyPort port = service.getPort();

    Client client = ClientProxy.getClient(port);
    client.getRequestContext().put(ENDPOINT_ADDRESS, endpointAddress);

    return port;
}

CXF seems to happily accept the FailoverFeature at boot time:

INFO  org.apache.cxf.clustering.FailoverTargetSelector - corid= Using failover strategy org.apache.cxf.clustering.RetryStrategy@36931450

But a request like the following won't retry because I get a (intended) "502: Connection refused" after about 2sek.

myPort.doSomething()

What am I doing wrong?


Solution

  • My workaround is now to use Spring's retry mechanism:

    @Retryable(
            value = {HTTPException.class},
            backoff = @Backoff(delay = 3000))
    public void callWebservice() { ... }