From c77322348c4518b40f0afdfd7f3e6f4a9f7fb481 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 1 May 2015 11:20:13 +0200 Subject: [PATCH] Add example for SEMAPHORE in @HystrixCommand --- .../main/asciidoc/spring-cloud-netflix.adoc | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/src/main/asciidoc/spring-cloud-netflix.adoc b/docs/src/main/asciidoc/spring-cloud-netflix.adoc index 428a8491..775cddaf 100644 --- a/docs/src/main/asciidoc/spring-cloud-netflix.adoc +++ b/docs/src/main/asciidoc/spring-cloud-netflix.adoc @@ -440,6 +440,26 @@ https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica# for more details. See the https://github.com/Netflix/Hystrix/wiki/Configuration[Hystrix wiki] for details on the properties available. +### Propagating the Security Context or using Spring Scopes + +If you want some thread local context to propagate into a `@HystrixCommand` the default declaration will not work because it executes the command in a thread pool (in case of timeouts). You can switch Hystrix to use the same thread as the caller using some configuration, or directly in the annotation, by asking it to use a different "Isolation Strategy". For example: + +[source,java] +---- +@HystrixCommand(fallbackMethod = "stubMyService", + commandProperties = { + @HystrixProperty(name="execution.isolation.strategy", value="SEMAPHORE") + } +) +... +---- + +The same thing applies if you are using `@SessionScope` or `@RequestScope`. You will know when you need to do this because of a runtime exception that says it can't find the scoped context. + +In particular you might be interested + +### Health Indicator + The state of the connected circuit breakers are also exposed in the `/health` endpoint of the calling application.