I am launching the spring boot application and just starting to integrate Hystrix from spring -cloud-netflix. I am using @HystrixCommand to transfer a service call to a service created using a fake client.
@HystrixCommand(fallbackMethod = "updateThingFallback") def updateRemoteThing(thingResourceClient: ThingResourceClient, thing: Thing) { thingResourceClient.updateThing(thing) // Call using feign client }
This feign client uses the spring security context to add security headers to the request it makes.
The problem I ran into is that when running HystrixCommand it starts in a separate thread from the Hystrix thread pool and when my code tries to access the spring security context, it is not available in the new thread.
I refer to the spring security context as follows:
SecurityContextHolder.getContext().getAuthentication();
My question is: does spring provide a way to pass spring security context (and application context) to Hystrix threads that run Hystrix commands?
source share