Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.15k stars 4.71k forks source link

hystrix not working with spring cacheable #1666

Open majidvodworks opened 7 years ago

majidvodworks commented 7 years ago

Hi All, I'm trying to use use spring cloud hystrix with spring cacheable annotation, it is not working. following is code sample

@Cacheable(value = "test", sync = true) @HystrixCommand(fallbackMethod="recoverGetValue") public String getValue(int id) { return id + ""; }

public String recoverGetValue(int id) { System.out.println("getting data from different resource"); return id + ""; }

Cacheable annotation throws operationTimeoutException, but fallback method is not being called. How to solve this issue?

davidkarlsen commented 7 years ago

Make sure you order the aspects /interceptors so they run in the order you want. Eg hystrix before cache

majidvodworks commented 7 years ago

I did but still it is not working Here is how I did it. @Bean @Order(value = Ordered.HIGHEST_PRECEDENCE) public HystrixCommandAspect hystrixAspect() { return new HystrixCommandAspect(); }

@EnableCaching(order= Ordered.LOWEST_PRECEDENCE)