Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:start"/>
    <hystrix>
      <to uri="http://fooservice.com/slow"/>
      <onFallback>
        <transform>
          <constant>Fallback message</constant>
        </transform>
      </onFallback>
    </hystrix>
    <to uri="mock:result"/>
  </route>
</camelContext>

onFallback vs onFallbackViaNetwork

If you are using onFallback then that is intended to be local processing only where you can do a message transformation or call a bean or something as the fallback. If you need to call an external service over the network then you should use onFallbackVisNetwork that processes that wraps that processing in another HystrixCommand that runs in its own thread pool to not saturn the first command using in the Hystrix EIP. 

Configuring Hystrix Example

...

Code Block
xml
xml
<camelContext xmlns="http://camel.apache.org/schema/spring">
 
  <!-- a shared config which you can refer to from all your hystrix EIPs -->
  <hystrixConfiguration id="sharedConfig" executionTimeoutInMilliseconds="5000" circuitBreakerSleepWindowInMilliseconds="10000"/>
 
  <route>
    <from uri="direct:start"/>
    <hystrix hystrixConfigurationRef="sharedConfig">
      <to uri="http://fooservice.com/slow"/>
      <onFallback>
        <transform>
          <constant>Fallback message</constant>
        </transform>
      </onFallback>
    </hystrix>
    <to uri="mock:result"/>
  </route>
</camelContext>

 

Example

You can find an example in the source code: camel-example-hystrix.