hystrix - javanica @HystrixCommand and spring @Cacheable execution order -


in spring application (not spring-boot), i'm using javanica @hystrixcommand annotation , spring cache @cacheable annotation on same bean method, spring execute cache advice before hystrix advice. it's i'm waiting, me cache advice , hystrix advice without configuration have same order in spring : lowest_precedence.

i wan't know make order : defined somewhere or undefined order , i'm lucky have order ? must done ensure cache advice executed before hystrix advice (set order on cache:annotation-driven before lowest_precedence ?)

this example of code :

... import org.springframework.cache.annotation.cacheconfig;  import org.springframework.cache.annotation.cacheable; import com.netflix.hystrix.contrib.javanica.annotation.hystrixcommand; import com.netflix.hystrix.contrib.javanica.annotation.hystrixproperty; ...   @service @slf4j @cacheconfig(cachemanager="mycachemanager") public class myressourcesimpl implements myressources { ...     @override     @hystrixcommand(commandproperties = {             @hystrixproperty(name = "execution.isolation.strategy", value = "semaphore"),             @hystrixproperty(name = "execution.isolation.thread.timeoutinmilliseconds", value = "10000") })     @cacheable("cachename")  //from spring cache     public map<string, string> getthemap() {         ...     } ...     } 

with spring config :

<bean id="mycache" class="org.springframework.cache.ehcache.ehcachemanagerfactorybean" >     <property name="configlocation" value="classpath:/meta-inf/...."  /> </bean>  <bean id="mycachemanager" class="org.springframework.cache.ehcache.ehcachecachemanager">     <property name="cachemanager" ref="mycache" /> </bean>  <cache:annotation-driven cache-manager="mycachemanager" />  <aop:aspectj-autoproxy/>  <bean id="hystrixaspect" class="com.netflix.hystrix.contrib.javanica.aop.aspectj.hystrixcommandaspect" /> 

thanks help

according docs, if don't specify order, undefined:

when 2 pieces of advice defined in different aspects both need run @ same join point, unless specify otherwise order of execution undefined. can control order of execution specifying precedence. done in normal spring way either implementing org.springframework.core.ordered interface in aspect class or annotating order annotation. given 2 aspects, aspect returning lower value ordered.getvalue() (or annotation value) has higher precedence.

credit: spring annotation advice order


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -