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-1456pull/1323/merge
parent
bf249d4205
commit
affb202e74
@ -0,0 +1,33 @@
|
||||
package org.test
|
||||
|
||||
@Grab("org.apache.activemq:activemq-all:5.4.0")
|
||||
@Grab("activemq-pool")
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@Log
|
||||
@EnableJms
|
||||
class SampleJmsListener implements CommandLineRunner {
|
||||
|
||||
private CountDownLatch latch = new CountDownLatch(1)
|
||||
|
||||
@Autowired
|
||||
JmsTemplate jmsTemplate
|
||||
|
||||
void run(String... args) {
|
||||
def messageCreator = { session ->
|
||||
session.createObjectMessage("Hello World")
|
||||
} as MessageCreator
|
||||
log.info "Sending JMS message..."
|
||||
jmsTemplate.send("testQueue", messageCreator)
|
||||
log.info "Sent JMS message, waiting..."
|
||||
latch.await()
|
||||
}
|
||||
|
||||
@JmsListener(destination = 'testQueue')
|
||||
def receive(String message) {
|
||||
log.info "Received ${message}"
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue