现在我正在使用RabbitMQ通过Java代码客户端使用消息,这是我的客户端代码:
@RabbitHandler
public void handle(@Payload byte[] message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
String messageContext = new String(message, "UTF-8");
ReportWalletConsumeRecord record = JSON.parseObject(messageContext, ReportWalletConsumeRecord.class);
asyncService.submit(() -> {
try {
MyContext.setTenant(record.getTenantId());
asyncFlushRecord(record, channel, tag);
} catch (Exception e) {
log.error("save message failed:" + JSON.toJSONString(record), e);
}
});
}
但是有时刷新失败并且消息变为unack,是否可以重新拉起unack消息并重试(1-3次)?