|
29 | 29 | import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext; |
30 | 30 | import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; |
31 | 31 | import com.netflix.hystrix.strategy.properties.HystrixProperty; |
| 32 | +import com.sun.javafx.collections.NonIterableChange; |
32 | 33 | import org.junit.After; |
33 | 34 | import org.junit.Rule; |
34 | 35 | import org.junit.Test; |
@@ -3940,6 +3941,43 @@ public void onNext(String s) { |
3940 | 3941 | System.out.println("ReqLog : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString()); |
3941 | 3942 | } |
3942 | 3943 |
|
| 3944 | + @Test |
| 3945 | + public void testRxRetry() throws Exception { |
| 3946 | + // see https://github.com/Netflix/Hystrix/issues/1100 |
| 3947 | + // Since each command instance is single-use, the expectation is that applying the .retry() operator |
| 3948 | + // results in only a single execution and propagation out of that error |
| 3949 | + HystrixCommand<Integer> cmd = getLatentCommand(ExecutionIsolationStrategy.THREAD, AbstractTestHystrixCommand.ExecutionResult.FAILURE, 300, |
| 3950 | + AbstractTestHystrixCommand.FallbackResult.UNIMPLEMENTED, 100); |
| 3951 | + |
| 3952 | + final CountDownLatch latch = new CountDownLatch(1); |
| 3953 | + |
| 3954 | + System.out.println(System.currentTimeMillis() + " : Starting"); |
| 3955 | + Observable<Integer> o = cmd.toObservable().retry(2); |
| 3956 | + System.out.println(System.currentTimeMillis() + " Created retried command : " + o); |
| 3957 | + |
| 3958 | + o.subscribe(new Subscriber<Integer>() { |
| 3959 | + @Override |
| 3960 | + public void onCompleted() { |
| 3961 | + System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " : OnCompleted"); |
| 3962 | + latch.countDown(); |
| 3963 | + } |
| 3964 | + |
| 3965 | + @Override |
| 3966 | + public void onError(Throwable e) { |
| 3967 | + System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " : OnError : " + e); |
| 3968 | + latch.countDown(); |
| 3969 | + } |
| 3970 | + |
| 3971 | + @Override |
| 3972 | + public void onNext(Integer integer) { |
| 3973 | + System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " : OnNext : " + integer); |
| 3974 | + } |
| 3975 | + }); |
| 3976 | + |
| 3977 | + latch.await(1000, TimeUnit.MILLISECONDS); |
| 3978 | + System.out.println(System.currentTimeMillis() + " ReqLog : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString()); |
| 3979 | + } |
| 3980 | + |
3943 | 3981 | /** |
3944 | 3982 | *********************** THREAD-ISOLATED Execution Hook Tests ************************************** |
3945 | 3983 | */ |
|
0 commit comments