我有一种情况,我想在hystrix请求折叠程序的批处理方法的后备上应用hystrix(并一一处理)。
后备方法(processEntryBatch_fallback
)被调用。但是不会报告hystrix命令(processEntryBackup
)的回退调用(甚至不会出现在仪表板上)。备用方法(finalFallback
)也不会被调用。
我想知道我在这里想念什么吗?
我提到了javanica documentation
@Service
public class DummyService {
private static final Logger log = LoggerFactory.getLogger(DummyService.class);
//batch processing method
public void processEntry(List<String> msg) {
//batch processing
throw new RuntimeException("Exception while batch processing");
}
//processing one-by-one
@HystrixCommand(fallbackMethod="finalFallback")
public void processEntryBackup(String msg) {
throw new RuntimeException("Exception while single processing");
}
public void finalFallback(String msg) {
log.info("logging..." + msg);
}
@HystrixCollapser(batchMethod = "processEntryBatch", collapserKey="ProcessEntryCollapser", scope=Scope.GLOBAL)
public Future<Object> processEntryCollapser(String msg) {
return null;
}
@HystrixCommand(fallbackMethod="processEntryBatch_fallback")
public List<Object> processEntryBatch(List<String> msgList) {
processEntry(msgList);
return new ArrayList<>(msgList);
}
public List<Object> processEntryBatch_fallback(List<String> msgList) {
for (String msg : msgList) {
processEntryBackup(msg);
}
return new ArrayList<>(msgList);
}
}