@ -1,8 +1,9 @@
package org . test
@Grab ( " org.apache.activemq:activemq-all:5.4.0 ")
@Grab ( " activemq-pool ")
@Grab ( " spring-boot-starter-hornetq ")
@Grab ( " hornetq-jms-server ")
import java.util.concurrent.CountDownLatch
import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl
@Log
@Configuration
@ -19,7 +20,6 @@ class JmsExample implements CommandLineRunner {
new DefaultMessageListenerContainer ( [
connectionFactory: connectionFactory ,
destinationName: "spring-boot" ,
pubSubDomain: true ,
messageListener: new MessageListenerAdapter ( new Receiver ( latch: latch ) ) { {
defaultListenerMethod = "receive"
} }
@ -28,7 +28,7 @@ class JmsExample implements CommandLineRunner {
void run ( String . . . args ) {
def messageCreator = { session - >
session . createObjectMessage ( "Greetings from Spring Boot via ActiveM Q")
session . createObjectMessage ( "Greetings from Spring Boot via Hornet Q")
} as MessageCreator
log . info "Sending JMS message..."
jmsTemplate . send ( "spring-boot" , messageCreator )
@ -44,4 +44,9 @@ class Receiver {
log . info "Received ${message}"
latch . countDown ( )
}
@Bean JMSQueueConfigurationImpl springBootQueue ( ) {
new JMSQueueConfigurationImpl ( 'spring-boot' , null , false )
}
}