2016-04-14 8 views
2

コードには、いくつかの@AsyncメソッドとApplicationListenersがあります。これらのクラスとメソッドは、@Hystrixアノテーションを持つAPIサービスを呼び出すことになります。これらの呼び出しは、次の例外をスロー:非同期メソッドでHystrixRequestContext.initializeContext()を追加Spring非同期メソッドまたはイベントスローHystrixRequestContext.initializeContext()例外

java.lang.IllegalStateException: HystrixRequestContext.initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used. 
at com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableDefault.get(HystrixRequestVariableDefault.java:76) ~[hystrix-core-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableHolder.get(HystrixRequestVariableHolder.java:68) ~[hystrix-core-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.HystrixRequestLog.getCurrentRequest(HystrixRequestLog.java:85) ~[hystrix-core-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.AbstractCommand.<init>(AbstractCommand.java:274) ~[hystrix-core-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:142) ~[hystrix-core-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:128) ~[hystrix-core-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.contrib.javanica.command.AbstractHystrixCommand.<init>(AbstractHystrixCommand.java:55) ~[hystrix-javanica-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.contrib.javanica.command.GenericCommand.<init>(GenericCommand.java:33) ~[hystrix-javanica-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.contrib.javanica.command.GenericHystrixCommandFactory.create(GenericHystrixCommandFactory.java:32) ~[hystrix-javanica-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.contrib.javanica.command.GenericHystrixCommandFactory.create(GenericHystrixCommandFactory.java:21) ~[hystrix-javanica-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.contrib.javanica.command.AbstractHystrixCommandFactory.create(AbstractHystrixCommandFactory.java:78) ~[hystrix-javanica-1.4.10.jar:1.4.10] 
at com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.methodsAnnotatedWithHystrixCommand(HystrixCommandAspect.java:81) ~[hystrix-javanica-1.4.10.jar:1.4.10] 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60] 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60] 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60] 
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60] 
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE] 
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE] 
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE] 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE] 
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE] 
at com.intuit.platform.common.aop.InstrumentationAspect.profile(InstrumentationAspect.java:25) ~[classes/:na] 
at sun.reflect.GeneratedMethodAccessor204.invoke(Unknown Source) ~[na:na] 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60] 
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60] 

は役立ちません。

答えて

0

要求が送信される前に値を初期化する必要があります。外部リソースへhttps://github.com/Netflix/Hystrix/issues/895

+0

リンクが奨励されているが、それはありますなぜあなたの仲間のユーザーはそれが何であるか、いくつかのアイデアを持っているとしますので、リンク周りのコンテキストを追加してください:Githubの詳細は、この問題を

HystrixRequestVariableDefault

をオーバーライド 。ターゲットサイトに到達できない場合や、永続的にオフラインになる場合は、常に重要なリンクの最も関連性の高い部分を引用してください。 – pableiros

関連する問題