使用Spring-雲Angel.SR6:春季雲Zuul重試當實例關閉
這裏是我的春天啓動的應用程序與@EnableZuulProxy配置:
server.port=8765
ribbon.ConnectTimeout=500
ribbon.ReadTimeout=5000
ribbon.MaxAutoRetries=1
ribbon.MaxAutoRetriesNextServer=1
ribbon.OkToRetryOnAllOperations=true
zuul.routes.service-id.retryable=true
我有2個實例運行在隨機端口上的service-id
。這些實例以及Zuul實例向Eureka成功註冊,我可以通過訪問http://localhost:8765/service-id/ ....來訪問實例上的RESTful端點,並發現它們以循環方式進行平衡。
我想殺掉其中一個service-id
實例,並且當這個不存在的實例接下來處於轉發狀態時,讓Zuul嘗試聯繫它,失敗並重試其他實例。
這是可能的,還是我誤解了文檔?當我嘗試上述配置時,針對已停止實例的請求'destined'失敗,併發生500次轉發錯誤。從Zuul堆棧跟蹤:
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:140)
....
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: service-idRibbonCommand timed-out and no fallback available
隨後的請求按預期成功。這種行爲一直持續到從Zuul的註冊表中刪除不存在的實例。
編輯:更新至Brixton.M5。行爲沒有變化。下面是詳細的豪豬例外:
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: service-id timed-out and no fallback available.
at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:806) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:790) ~[hystrix-core-1.4.23.jar:1.4.23]
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:99) ~[rxjava-1.0.14.jar:1.0.14]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1521) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1411) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:314) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:306) ~[hystrix-core-1.4.23.jar:1.4.23]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:162) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable$2.call(Observable.java:154) ~[rxjava-1.0.14.jar:1.0.14]
at rx.Observable.unsafeSubscribe(Observable.java:7710) ~[rxjava-1.0.14.jar:1.0.14]
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:100) ~[rxjava-1.0.14.jar:1.0.14]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.14.jar:1.0.14]
at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1.run(AbstractCommand.java:958) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:41) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:37) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable.run(HystrixContextRunnable.java:57) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$2.tick(AbstractCommand.java:978) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.util.HystrixTimer$1.run(HystrixTimer.java:100) ~[hystrix-core-1.4.23.jar:1.4.23]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_66]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[na:1.8.0_66]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_66]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
... 1 common frames omitted
Caused by: java.util.concurrent.TimeoutException: null
at com.netflix.hystrix.AbstractCommand$9.call(AbstractCommand.java:601) ~[hystrix-core-1.4.23.jar:1.4.23]
at com.netflix.hystrix.AbstractCommand$9.call(AbstractCommand.java:581) ~[hystrix-core-1.4.23.jar:1.4.23]
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:99) ~[rxjava-1.0.14.jar:1.0.14]
... 15 common frames omitted
它適用於Brixton快照。我沒有設置所有這些「ribbon。*」屬性,所以也許這實際上是以某種方式傷害了,或者它可能只適用於較新的堆棧?你可以試試布里克斯頓? –
你可以顯示'zuul.routes'配置的其餘部分。你在做GET操作嗎? – spencergibb
@DaveSyer我切換到Brixton.M5並刪除了'ribbon。*'屬性,但它沒有任何區別。我注意到,我不必設置'eureka.instance.metadata.instanceId',而必須設置'eureka.instance。instanceId'來區分我的實例(它們在'server.port = 0'上運行的b/c)。 – grinder