Spring cloud 春云海斯特里克斯酒店

Spring cloud 春云海斯特里克斯酒店,spring-cloud,hystrix,Spring Cloud,Hystrix,我正在使用SpringCloud brixton.m5做一些工作,并尝试让AsyncRestTemplate异步地将多个微服务调用组合到一个协调服务响应中。我在这里找到了spencer gibb的MyFeed github项目,该项目使AsyncRestTemplate与ribbon一起工作,但当我有一个用@HystrixCommand注释的方法返回CompletableFuture时,我遇到了麻烦,如下所示: public List<Order> getCustomerOrders

我正在使用SpringCloud brixton.m5做一些工作,并尝试让AsyncRestTemplate异步地将多个微服务调用组合到一个协调服务响应中。我在这里找到了spencer gibb的MyFeed github项目,该项目使AsyncRestTemplate与ribbon一起工作,但当我有一个用@HystrixCommand注释的方法返回CompletableFuture时,我遇到了麻烦,如下所示:

public List<Order> getCustomerOrdersFallback(int customerId) {
    return Collections.emptyList();
}

@HystrixCommand(fallbackMethod = "getCustomerOrdersFallback")
@Override
public CompletableFuture<List<Order>> getCustomerOrders(int customerId) {
    ListenableFuture<ResponseEntity<List<Order>>> ordersFuture = restTemplate.exchange(
            "http://order-service/orders?customerId={customerId}", HttpMethod.GET, null,
            new ParameterizedTypeReference<List<Order>>() {
            }, customerId);
    return CompletableFutureUtils.convert(ordersFuture);
}

如果我将@HystrixCommand注释从getCustomerOrders中移除,调用可以正常工作,但我当然会丢失hystrix功能。

我最终从使用CompletableFuture切换到rx.Observable,这是由hystrix/javanica支持的。

我不确定
@HystrixCommand
是否支持返回
CompletableFuture
。有关有效的执行模式,请参阅。myfeed项目已经有一段时间没有更新了,因此以后的版本可能会出现问题。
java.lang.ClassCastException: rx.internal.operators.BlockingOperatorToFuture$2 cannot be cast to java.util.concurrent.CompletableFuture
at com.sun.proxy.$Proxy86.getCustomerOrders(Unknown Source) ~[na:na]
at com.build.coordination.service.CustomerServiceImpl.getCustomerOrderView(CustomerServiceImpl.java:50) ~[classes/:na]
at com.build.coordination.customer.CustomerController.getCustomerOrderView(CustomerController.java:45) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72-internal]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72-internal]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72-internal]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72-internal]