spring cloud - Log errors from hystrix commands -


with @hystrixcommand annotation there can configured fallback method should run in case method fails.

    public link defaultdogelink(account account) {          return null;     }      @hystrixcommand(fallbackmethod = "defaultdogelink")     public link builddogelink(account account) {          // code may throw runtime exceptions     }   

what should in order log (in central class) runtime exceptions thrown in methods annotated @hystrixcommand ?

i using spring-cloud-netflix , not vanilla hystrix-javanica. looking similar org.springframework.aop.interceptor.asyncuncaughtexceptionhandler class (for spring's @async) need implement in application.

in hystrix-core, hystrixcommand class has method getfailedexecutionexception() can used within fallback method logging exception. can maybe point me how exception when working hystrix-javanica?

i found within unit tests of hystrix-javanica way last executed hystrix command:

public link defaultdogelink(account account) {      log.warn("exception occured while building doge link account " + account, getcommand().getfailedexecutionexception());      return null; }  @hystrixcommand(fallbackmethod = "defaultdogelink") public link builddogelink(account account) {      // code may throw runtime exceptions }     private com.netflix.hystrix.hystrixinvokableinfo<?> getcommand() {     return hystrixrequestlog.getcurrentrequest().getallexecutedcommands().iterator().next(); } 

it bit more verbose expected, fulfills requirement.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -