CXF RetryStrategy不适用于Soap Web服务

时间:2019-06-18 12:13:17

标签: spring soap cxf

我将CXF用于SOAP Web服务客户端,并且以某种方式,我无法获得有效的RetryStrategy作为FailoverFeature。另一个LoggingFeature运行正常。这是我的Spring配置:

@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似乎很高兴在启动时接受FailoverFeature:

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

但是像下面这样的请求不会重试,因为大约2秒后我收到了(打算)“ 502:连接被拒绝”。

myPort.doSomething()

我在做什么错了?

1 个答案:

答案 0 :(得分:0)

我的解决方法是使用Spring的重试机制:

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