gpt4 book ai didi

spring-boot - 如何使用最新的SpringBoot和ActiveMQ classic将消息放回队列

转载 作者:行者123 更新时间:2023-12-03 08:44:05 26 4
gpt4 key购买 nike

我正在设计一个简单的系统,流程将如下所示:
Message Producer Microservice --> Active MQ --> Message Consumer Microservice --> Mongo DB
我需要以某种方式设计一种排队策略,以便在MongoDB关闭时不会丢失消息(因为消息使用者将使消息出队)。

我的消费者是这样写的:

    @JmsListener(destination = "Consumer.myconsumer.VirtualTopic.Tracking")
public void onReceiveFromQueueConsumer2(TrackingRequest trackingRequest) {
log.debug("Received tracking request from the queue by consumer 2");
log.debug(trackingRequest.toString());
}

您如何提供客户确认?

最佳答案

您可以从“消息使用者微服务”中使用客户端确认模式。由于您使用的是Spring JmsListener,因此可以使用 containerFactory 定义侦听器容器,然后可以使用sessionAcknowledgeMode在侦听器容器上设置所需的模式。有关您可能想在此处使用哪种确认模式的更多详细信息,请参见the Spring documentation

从ActiveMQ客户端的 Angular 来看,您可以配置重新交付语义,但是如果发生故障,可以根据需要进行配置。有关更多信息,请参见ActiveMQ documentation

关于spring-boot - 如何使用最新的SpringBoot和ActiveMQ classic将消息放回队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58793859/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com