In the documentation related to here ,
Request caching is activated by implementing the getCacheKey() method for the HystrixCommand ...
You have not implemented getCacheKey() ,
@Override protected String getCacheKey() { return String.valueOf(id);
Then you will also need a HystrixRequestContext
HystrixRequestContext context = HystrixRequestContext.initializeContext();
What (again, in the documentation)
Typically, this context will be initialized and terminated with a ServletFilter that wraps the user request or some other lifecycle binding.
Then I believe that you cannot change the signature of the execute() method ( doExecute() not part of the interface) instead, you pass the parameter to your command constructor and please annotate execute with @Override to get a compiler error if you forgot and then
HystrixRequestContext context = HystrixRequestContext.initializeContext(); GetFizzCommand commandA = new GetFizzCommand(2L); GetFizzCommand commandB = new GetFizzCommand(2L); Fizz a = commandA.execute();
Elliott frisch
source share