The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Denis Zinovyev (2) [Avatar] Offline
Hi John,

Thank you for this book!
I've just finished chapter 5 today. I have a question about changing default HystrixConcurrencyStrategy instance.

Could we just use InheritableThreadLocal instance for userContext variable instead of changing default HystrixConcurrencyStrategy instance?

public class UserContextHolder {
    private static final ThreadLocal<UserContext> userContext = new InheritableThreadLocal<>();

Are there any reasons to use approach described in chapter 5?

Thanks in advance,
joshuawhite929 (16) [Avatar] Offline

Your right in thinking that the InheritableThreadLocal will copy thread local variables from the Parent when it is created. The challenge is that Hystrix (when configured to use threads) will pool these threads. As a result, this approach would only work the first time the thread is created. When the thread is reused, you would not get the results you would expect.

Denis Zinovyev (2) [Avatar] Offline
It is clear. Thank you for the quick reply!
John C Carnell (44) [Avatar] Offline
Hi Josh,

Many thanks for responding.