Skip to content

Commit 9b598b4

Browse files
committed
Fix JMS support in the CLI
Partly back port changes from affb202 and 85c9574 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
1 parent c9a3919 commit 9b598b4

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

spring-boot-cli/samples/jms.groovy

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.test
22

3-
@Grab("org.apache.activemq:activemq-all:5.4.0")
4-
@Grab("activemq-pool")
3+
@Grab("spring-boot-starter-hornetq")
4+
@Grab("hornetq-jms-server")
55
import java.util.concurrent.CountDownLatch
6+
import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl
67

78
@Log
89
@Configuration
@@ -19,7 +20,6 @@ class JmsExample implements CommandLineRunner {
1920
new DefaultMessageListenerContainer([
2021
connectionFactory: connectionFactory,
2122
destinationName: "spring-boot",
22-
pubSubDomain: true,
2323
messageListener: new MessageListenerAdapter(new Receiver(latch:latch)) {{
2424
defaultListenerMethod = "receive"
2525
}}
@@ -28,7 +28,7 @@ class JmsExample implements CommandLineRunner {
2828

2929
void run(String... args) {
3030
def messageCreator = { session ->
31-
session.createObjectMessage("Greetings from Spring Boot via ActiveMQ")
31+
session.createObjectMessage("Greetings from Spring Boot via HornetQ")
3232
} as MessageCreator
3333
log.info "Sending JMS message..."
3434
jmsTemplate.send("spring-boot", messageCreator)
@@ -44,4 +44,9 @@ class Receiver {
4444
log.info "Received ${message}"
4545
latch.countDown()
4646
}
47+
48+
@Bean JMSQueueConfigurationImpl springBootQueue() {
49+
new JMSQueueConfigurationImpl('spring-boot', null, false)
50+
}
51+
4752
}

spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/JmsCompilerAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* {@link CompilerAutoConfiguration} for Spring JMS.
2929
*
3030
* @author Greg Turnquist
31+
* @author Stephane Nicoll
3132
*/
3233
public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
3334

@@ -41,8 +42,7 @@ public boolean matches(ClassNode classNode) {
4142
@Override
4243
public void applyDependencies(DependencyCustomizer dependencies)
4344
throws CompilationFailedException {
44-
dependencies.add("spring-jms", "geronimo-jms_1.1_spec");
45-
45+
dependencies.add("spring-jms", "jms-api");
4646
}
4747

4848
@Override

spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,10 @@ public void txSample() throws Exception {
134134
}
135135

136136
@Test
137-
@Ignore("Intermittent failure on CI. See #323")
138137
public void jmsSample() throws Exception {
139138
String output = this.cli.run("jms.groovy");
140139
assertTrue("Wrong output: " + output,
141-
output.contains("Received Greetings from Spring Boot via ActiveMQ"));
142-
FileUtils.deleteDirectory(new File("activemq-data"));// cleanup ActiveMQ cruft
140+
output.contains("Received Greetings from Spring Boot via HornetQ"));
143141
}
144142

145143
@Test

0 commit comments

Comments
 (0)