我正在尝试使用 Quarkus 的容错功能,但我坚持使用 @Retry 和 Mutiny。
我有这些方法:
@Transactional
@TransactionConfiguration(timeout = 30)
@Incoming("ocr-in")
@Retry(delay = 5000, maxRetries = 2)
@Fallback(fallbackMethod = "removerProcessamento")
protected Uni<Void> recebeEvento(Message<String> ocr) {
log.infof("OCR %s RECEBIDO", ocr.getPayload());
return getUni(ocr);
}
private Uni<Void> getUni(Message<String> ocr) {
return Uni.createFrom().item(ocr)
.onItem()
.invoke(this::processar)
.replaceWith(ocr::ack)
.replaceWithVoid();
}
protected Uni<Void> removerProcessamento(Message<String> ocr) {
log.errorf("ERRO O PROCESSAMENTO DO OCR %s, REMOVENDO REGISTROS", ocr.getPayload());
pecaService.limparProcessamentoOcr(Long.valueOf(ocr.getPayload()));
return Uni.createFrom().item(ocr).replaceWith(() -> ocr.nack(new RuntimeException())).replaceWithVoid();
}
我试图在事务超时发生时重试,但它永远不会发生!发生超时,不再调用该方法。
我认为我需要归还大学的一些东西。 有没有办法实现这个目标?