I am trying to create an ActiveMQ Artemis queue with last-value property enabled.
My app is using Spring Boot 2.2.6, and i am using Artemis as an embedded broker.
Spring Boot has a spring.artemis.embedded.queues
property, which i tried to set as follows:
spring.artemis.embedded.queues: myqueue?last-value-key=code
But that doesn't seem to work.
The Artemis documentation mentions 2 ways of configuring the queue:
- Using a
broker.xml
configuration file, but i couldn't make this work. - Getting hold of a CORE session object, but I didn't manage to get hold of that object via Spring.
Is there an easy way to configure a last-value queue using Spring Boot, either via application.yml
, or via Java/Kotlin configuration ?
Here is my test code:
@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)
}
}