从rabbitMQ跟踪电子邮件状态

时间:2019-05-13 13:11:28

标签: spring-boot rabbitmq

我正在使用RabbitMQ和spring boot跟踪电子邮件状态, 我无法获取已发送邮件的状态

在这里,我编写的代码可以正常工作,但是我无法获得电子邮件(消息)状态

@Selector(type = SelectorType.TYPE, value = "com.ads.messaging.bus.events.DeliveryEvent")
    public void handle(DeliveryEvent event) {
        Channel channel = event.getChannel();
        long deliveryTag = event.getDeliveryTag();
        boolean delivered = event.isDelivered();
        MessageTypeEnum type = event.getType();
        try {
            if (delivered) {
                channel.basicAck(deliveryTag, false);
                counters.get(type).getLeft().inc();
            } else {
                counters.get(type).getRight().inc();
                channel.basicNack(deliveryTag, false, true);
            }
            LOGGER.info("{} sent for message {}", delivered ? "Ack" : "Nack",
                    deliveryTag);
        } catch (IOException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }

最后,我希望将状态保存在数据库中并具有类似的功能 https://i.stack.imgur.com/7PD91.png

0 个答案:

没有答案