CXF RetryStrategy 不适用于 Soap Webservice
CXF RetryStrategy not working for Soap Webservice
我正在将 CXF 用于 SOAP 网络服务客户端,但不知何故,我无法将有效的 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()
我做错了什么?
我现在的解决方法是使用 Spring 的重试机制:
@Retryable(
value = {HTTPException.class},
backoff = @Backoff(delay = 3000))
public void callWebservice() { ... }
我正在将 CXF 用于 SOAP 网络服务客户端,但不知何故,我无法将有效的 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()
我做错了什么?
我现在的解决方法是使用 Spring 的重试机制:
@Retryable(
value = {HTTPException.class},
backoff = @Backoff(delay = 3000))
public void callWebservice() { ... }