Fix JMS support in the CLI

Partly back port changes from affb202e and 85c95744f to fix the usage
of JMS in the CLI. Restore the integration test using HornetQ and fix the
coordinates of the JMS API.

Fixes gh-2075
This commit is contained in:
Stephane Nicoll 2014-12-08 08:39:47 +01:00
parent c9a3919af9
commit 9b598b49c2
3 changed files with 12 additions and 9 deletions

View File

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

View File

@ -28,6 +28,7 @@ import org.springframework.boot.groovy.EnableJmsMessaging;
* {@link CompilerAutoConfiguration} for Spring JMS. * {@link CompilerAutoConfiguration} for Spring JMS.
* *
* @author Greg Turnquist * @author Greg Turnquist
* @author Stephane Nicoll
*/ */
public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration { public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
@ -41,8 +42,7 @@ public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
@Override @Override
public void applyDependencies(DependencyCustomizer dependencies) public void applyDependencies(DependencyCustomizer dependencies)
throws CompilationFailedException { throws CompilationFailedException {
dependencies.add("spring-jms", "geronimo-jms_1.1_spec"); dependencies.add("spring-jms", "jms-api");
} }
@Override @Override

View File

@ -134,12 +134,10 @@ public class SampleIntegrationTests {
} }
@Test @Test
@Ignore("Intermittent failure on CI. See #323")
public void jmsSample() throws Exception { public void jmsSample() throws Exception {
String output = this.cli.run("jms.groovy"); String output = this.cli.run("jms.groovy");
assertTrue("Wrong output: " + output, assertTrue("Wrong output: " + output,
output.contains("Received Greetings from Spring Boot via ActiveMQ")); output.contains("Received Greetings from Spring Boot via HornetQ"));
FileUtils.deleteDirectory(new File("activemq-data"));// cleanup ActiveMQ cruft
} }
@Test @Test