hystrix封装依赖调用架构如下所示:

hystrix总结

流程图:

hystrix总结

四种调用方式,前两种只适用于HystrixCommand,不适用于HystrixObservableCommand

  • execute() — blocks, then returns the single response received from the dependency (or throws an exception in case of an error)
  • queue() — returns a Future with which you can obtain the single response from the dependency
  • observe() — subscribes to the Observable that represents the response(s) from the dependency and returns an Observable that replicates that source Observable
  • toObservable() — returns an Observable that, when you subscribe to it, will execute the Hystrix command and emit its responses
K             value   = command.execute();
Future<K>     fValue  = command.queue();
Observable<K> ohValue = command.observe();         //hot observable
Observable<K> ocValue = command.toObservable();    //cold observable
缓存流程示意图:

hystrix总结

没有办法强制使超时的线程停止执行,hystrix可以抛出一个InterruptException异常,如果这个包装类InterruptException异常。

对于线程中断,Hystrix不能保证中断实际发生。像在JVM上运行的所有其他代码一样,您只能抛出一个InterruptedException,您不能强制包装的代码来捕获它。


相关文章:

  • 2021-11-12
  • 2021-05-08
  • 2021-06-21
  • 2021-12-13
  • 2021-09-13
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2021-09-02
  • 2021-09-15
  • 2022-12-23
  • 2021-09-19
  • 2022-02-08
  • 2022-02-27
相关资源
相似解决方案