I'm running a spring boot app and just starting to integrate Hystrix from spring-cloud-netflix. I'm using @HystrixCommand to wrap a service-to-service call made with a feign 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'm having is that when the HystrixCommand is executed it is run in a separate thread from a Hystrix thread pool and when my code tries to access the spring security context it is not available on the new thread.
I'm accessing the spring security context like this:
SecurityContextHolder.getContext().getAuthentication();
My Question is, does spring provide a way of passing the spring security context (and the application context) to the Hystrix threads that are running the Hystrix commands?