HystrixCollapser UnmanagedThreadException on command creation
I'm using the ratpack hystrix module along with a globally scoped collapser. Creating a new command via the collapser createCommand method results in an UnmanagedThreadException when attempting to initialize the HystrixRequestLog. I've noticed the recommendation to use HystrixObservableCommand with ratpack, however, the HystrixCollapser interface doesn't allow this.
Looking for recommendations when request batching via the HystrixCollapser and integrating with Ratpack. Thanks.
ratpack.exec.UnmanagedThreadException: Operation attempted on non Ratpack managed thread 'HystrixTimer-1'
at ratpack.exec.internal.DefaultExecution.require(DefaultExecution.java:104) ~[ratpack-core-1.4.5.jar:na]
at ratpack.exec.Execution.current(Execution.java:81) ~[ratpack-core-1.4.5.jar:na]
at ratpack.hystrix.internal.HystrixRegistryBackedRequestVariable.getExecution(HystrixRegistryBackedRequestVariable.java:53) ~[ratpack-hystrix-1.4.5.jar:na]
at ratpack.hystrix.internal.HystrixRegistryBackedRequestVariable.get(HystrixRegistryBackedRequestVariable.java:34) ~[ratpack-hystrix-1.4.5.jar:na]
at com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableHolder.get(HystrixRequestVariableHolder.java:68) ~[hystrix-core-1.5.9.jar:1.5.9]
at com.netflix.hystrix.HystrixRequestLog.getCurrentRequest(HystrixRequestLog.java:85) ~[hystrix-core-1.5.9.jar:1.5.9]
at com.netflix.hystrix.AbstractCommand.initRequestLog(AbstractCommand.java:286) ~[hystrix-core-1.5.9.jar:1.5.9]
at com.netflix.hystrix.AbstractCommand.<init>(AbstractCommand.java:177) ~[hystrix-core-1.5.9.jar:1.5.9]
at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:148) ~[hystrix-core-1.5.9.jar:1.5.9]
at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:134) ~[hystrix-core-1.5.9.jar:1.5.9]
The problem is that when using a collapser the commands are ultimately created from a HystrixTimer. And because Ratpack's Hystrix module provides a Ratpack execution backed concurrency strategy, it expects that all commands will be created from a Ratpack execution.
I can't see a way around this at the moment without being able to provide a Ratpack HystrixTimer implementation that will run on an execution. This would also solve a different problem I've been having too. I will have to raise a Hystrix issue for this.
It is possible to use a collapser in Ratpack just by not using that Hystrix module. Unfortunately, doing that would would mean losing request caching and the metric streaming.
Re: HystrixCollapser UnmanagedThreadException on command creation
I'll keep an eye out for the issue. I noticed the workaround to disable the hystrix request logging but wasn't sure about the impact so thank you for clarifying. Would love to have the streaming metrics but fortunately request caching isn't currently a necessity for us. It still seems relatively important as far as integrating with hystrix goes to be able to use that module.