我有两个要调用的api。它们都用 Hystrix Observable 包裹:
这是一个例子:
@HystrixCommand()
public Observable<String> getAvailableFlightBookings() {
return new ObservableResult<String>() {
@Override
public String invoke() {
URI uri = registryService.getServiceUrl("flight-booking-service", "http://localhost:8081/flight-booking-service");
String url = uri.toString() + "/flights/list";
ResponseEntity<String> resultStr = restTemplate.getForEntity(url, String.class);
return resultStr.getBody();
}
};
}
我有以下代码,我正在努力完成:
public DeferredResult<FlightDetails> getAllFlightDetails() {
//Calling previous defined functions
Observable<String> availableFlightBookings=flightBookingIntegrationService.getAvailableFlightBookings();
Observable<String> couponId=couponIntegrationService.getCoupon();
Observable<String> details = Observable.zip(
..?
}
我不确定如何调用以下 API:
flightBookingIntegrationService.getAvailableFlightBookings();
couponIntegrationService.getCoupon();
并使用 Observable.zip 填充最终结果对象 (FlightDetails)
航班详情:
public class FlightDetails {
String couponId;
String availableFlightList;
..
}
谢谢你,雷。