Improve JMS support in cli

This commit deprecates the proprietary EnableJmsMessaging annotation in
favour of the standard @EnableJms introduced as of Spring 4.1. This
commit also updates the sample and adds an integration test as the
feature was actually broken.

Fixes gh-1456
This commit is contained in:
Stephane Nicoll
2014-08-28 14:25:14 +02:00
parent bf249d4205
commit affb202e74
5 changed files with 56 additions and 26 deletions

View File

@@ -5,8 +5,7 @@ package org.test
import java.util.concurrent.CountDownLatch
@Log
@Configuration
@EnableJmsMessaging
@EnableJms
class JmsExample implements CommandLineRunner {
private CountDownLatch latch = new CountDownLatch(1)
@@ -14,18 +13,6 @@ class JmsExample implements CommandLineRunner {
@Autowired
JmsTemplate jmsTemplate
@Bean
DefaultMessageListenerContainer jmsListener(ConnectionFactory connectionFactory) {
new DefaultMessageListenerContainer([
connectionFactory: connectionFactory,
destinationName: "spring-boot",
pubSubDomain: true,
messageListener: new MessageListenerAdapter(new Receiver(latch:latch)) {{
defaultListenerMethod = "receive"
}}
])
}
void run(String... args) {
def messageCreator = { session ->
session.createObjectMessage("Greetings from Spring Boot via ActiveMQ")
@@ -35,13 +22,10 @@ class JmsExample implements CommandLineRunner {
log.info "Send JMS message, waiting..."
latch.await()
}
}
@Log
class Receiver {
CountDownLatch latch
@JmsListener(destination = 'spring-boot')
def receive(String message) {
log.info "Received ${message}"
latch.countDown()
}
}
}