JmsListener 重启时不会在队列中获取消息。如何在重启时获取所有消息?

问题描述 投票:0回答:0

我有一个 Spring Boot 应用程序可以监听来自 Artemis 的消息。

我注意到如果我停止侦听器应用程序,发送消息 A 并重新启动应用程序,则不会检索到消息 A。

当我在监听器启动时发送另一条消息 B 时,消息 A 和 B 都被检索到。

如何强制我的应用程序在启动时处理队列中的所有消息?

这是 Artemis 配置:

spring:
  activemq:
    packages:
      trust-all: true
  artemis:
    host: localhost
    port: 61616
    user: xxx
    password: xxx
    embedded:
      queues: TEST

这是听众:

@Component
public class MessageConsumer {
    @JmsListener(destination = "${spring.artemis.embedded.queues}")
    public void messageListener(String message){
        // message is processed
    }
}

Artemis 队列是默认的 TEST 队列。

spring-boot spring-jms activemq-artemis
© www.soinside.com 2019 - 2024. All rights reserved.