Skip to content

Context Propagation

enadim edited this page Nov 14, 2017 · 2 revisions

Principle

The context propagation comes with default strategies for Histrix, Zuul, Feign, spring & java executors, http request, jms, stomp.

The default strategies will preserves the execution context within any async call and will propagate this execution context to downstream services using Http Headers, Stomp Headers or Jms message properties.

The context propagation can enable sharing the current zone with down stream services.

Usage

@SpringBootApplication
@EnableContextPropagation
public class Application{
...
}

Configuration

Default configuration

ribbon.extensions.propagation.upStreamZone.enabled=true
ribbon.extensions.propagation.upStreamZone.key=upstream-zone

Minimal configuration

Should set at least the propagation keys (by default it is empty).

ribbon.extensions.propagation.keys[0]=upstream-zone
ribbon.extensions.propagation.keys[1]=favorite-zone

Disabling all components

The propagation can be disabled for all component using

ribbon.extensions.propagation.enabled=false

Disabling at component level

Programmatically

@SpringBootApplication
@EnableContextPropagation(
    inboundHttpRequest=false,
    feign=false,
    executor=false,
    zuul=false,
    hystrix=false,
    jms=false,
    stomp=false,
public class Application{
...
}

Using properties

ribbon.extensions.propagation.inboundHttpRequest.enabled=false
ribbon.extensions.propagation.feign.enabled=false
ribbon.extensions.propagation.executor.enabled=false
ribbon.extensions.propagation.zuul.enabled=false
ribbon.extensions.propagation.hystrix.enabled=false
ribbon.extensions.propagation.jms.enabled=false
ribbon.extensions.propagation.stomp.enabled=false

Customization

The propagation strategy can be configured at component level.

Default strategies are defined at the annotation @EnableContextPropagation itself

Example:

@SpringBootApplication
@EnableContextPropagation(
    inboundHttpRequestStrategy=YourCustomInboundHttpRequestStrategy.class,
    feignStrategy=YourCustomFeignStrategy.class,
    executorStrategy=YourCustomExecutorStrategy.class,
    zuulStrategy=YourCustomZuulStrategy.class,
    hystrixStrategy=YourCustomHystrixStrategy.class,
    jmsStrategy=YourCustomJmsStrategy.class,
    stompStrategy=YourCustomStompStrategy.class,
public class Application{
...
}

Clone this wiki locally