【发布时间】:2020-08-05 11:40:32
【问题描述】:
我正在尝试创建一个启用了last-value 属性的 ActiveMQ Artemis 队列。
我的应用使用 Spring Boot 2.2.6,并且我使用 Artemis 作为嵌入式代理。
Spring Boot 有一个spring.artemis.embedded.queues 属性,我尝试设置如下:
spring.artemis.embedded.queues: myqueue?last-value-key=code
但这似乎不起作用。
Artemis 文档提到了 2 种配置队列的方法:
- 使用
broker.xml配置文件,但我无法完成这项工作。 - 获取了一个 CORE 会话对象,但我没有设法通过 Spring 获取该对象。
有没有一种简单的方法可以通过 application.yml 或通过 Java/Kotlin 配置使用 Spring Boot 配置最后值队列?
这是我的测试代码:
@ExtendWith(SpringExtension::class)
@SpringBootTest
class ArtemisTest(
@Autowired private val jmsTemplate: JmsTemplate
) {
@Test
fun testMessage() {
for(i in 1..5) {
jmsTemplate.convertAndSend(
"myqueue",
"message $i"
) {
it.also { it.setStringProperty("code", "1") }
}
}
val size = jmsTemplate.browse("myqueue") { _: Session, browser: QueueBrowser ->
browser.enumeration.toList().size
}
assertThat(size).isEqualTo(1)
}
}
【问题讨论】:
标签: spring-boot kotlin activemq-artemis