代码之家  ›  专栏  ›  技术社区  ›  Dolphin

是否可以在RabbitMQ中重试unack消息

  •  0
  • Dolphin  · 技术社区  · 4 年前

    现在,我使用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次)?

    0 回复  |  直到 4 年前