问题描述
我是Netflix的开源项目的忠实粉丝。他们做了一些非常酷的东西。
我建立了一个Zuul,工作正常。创建了所有类型的过滤器,并且这些过滤器被动态加载并运行
我现在要做的是在过滤器中使用Hystrix。我所看到的是,如果一切顺利,一切正常。但是,当run()方法内部存在异常时,Zuul会捕获它而不是Hystrix。所以getFallback()永远不会被调用。
我分享了我的代码。
有人知道Hystrix是如何捕捉异常而不是Zuul的?
我认为这个问题实际上与你如何执行你的hystrix命令有关。尝试调用而不是。我怀疑发生了什么是run()只是抛出异常,而execute()会捕获它并调用getFallback()。
I'm a big fan of the Open Source project of Netflix. They made some really cool stuff.
I have set up a Zuul and that is working fine. Created all kind of filters and those are dynamically loaded and run.
What I now try to do is use Hystrix inside a filter. What I see is that if everything when fine it all works. But when there is a exception inside the run() method Zuul is catching it instead of Hystrix. So the getFallback() is never called.
I shared my code Github.
Somebody has any idea how Hystrix can catch the exception instead of Zuul?
I think the issue is actually with how you are executing your hystrix command. Try calling execute() instead of run(). I suspect that what's happening is run() is simply throwing the exception whereas execute() will catch it and call getFallback().
这篇关于将Netflix Zuul与Netflix Hystrix相结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!