问题描述
假设我有以下控制器:
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@Slf4j
@DefaultProperties(defaultFallback = "globalHandler.payment_Global_FallbackMethod")
public class OrderHystirxController
{
@GetMapping("/consumer/payment/hystrix/timeout/{id}")
@HystrixCommand(commandProperties = {
@HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds",value="1500")
})
public String paymentInfo_TimeOut(@PathVariable("id") Integer id)
{
return "aaa";
}
}
@DefaultProperties(defaultFallback = "globalHandler.payment_Global_FallbackMethod")
我想表达的意思是,创建一个带有Payment_Global_FallbackMethod函数的GlobalHandler类组件,尝试让其他控制器共享使用它。有可能吗?
import org.springframework.stereotype.Component;
@Component
public class GlobalHandler
{
public String payment_Global_FallbackMethod()
{
return "[GlobalHandler][payment_Global_FallbackMethod],Global level fallback";
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)