Skip to content

Commit 94e542c

Browse files
committed
WIP: Reinstate support for auto-configuring an embedded ActiveMQ broker
1 parent 77089a1 commit 94e542c

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ dependencies {
7878
optional("jakarta.servlet:jakarta.servlet-api")
7979
optional("javax.cache:cache-api")
8080
optional("org.apache.activemq:activemq-client")
81+
optional("org.apache.activemq:activemq-broker")
8182
optional("org.apache.commons:commons-dbcp2") {
8283
exclude group: "commons-logging", module: "commons-logging"
8384
}

spring-boot-project/spring-boot-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ dependencies {
7777
optional("javax.cache:cache-api")
7878
optional("javax.money:money-api")
7979
optional("org.apache.activemq:activemq-client")
80+
optional("org.apache.activemq:activemq-broker")
8081
optional("org.apache.activemq:artemis-jakarta-client") {
8182
exclude group: "commons-logging", module: "commons-logging"
8283
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQProperties.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@
3737
@ConfigurationProperties(prefix = "spring.activemq")
3838
public class ActiveMQProperties {
3939

40+
private static final String DEFAULT_EMBEDDED_BROKER_URL = "vm://localhost?broker.persistent=false";
41+
4042
private static final String DEFAULT_NETWORK_BROKER_URL = "tcp://localhost:61616";
4143

4244
/**
4345
* URL of the ActiveMQ broker. Auto-generated by default.
4446
*/
4547
private String brokerUrl;
4648

49+
/**
50+
* Whether the default broker URL should be in memory. Ignored if an explicit broker
51+
* has been specified.
52+
*/
53+
private boolean inMemory = true;
54+
4755
/**
4856
* Login user of the broker.
4957
*/
@@ -83,6 +91,14 @@ public void setBrokerUrl(String brokerUrl) {
8391
this.brokerUrl = brokerUrl;
8492
}
8593

94+
public boolean isInMemory() {
95+
return this.inMemory;
96+
}
97+
98+
public void setInMemory(boolean inMemory) {
99+
this.inMemory = inMemory;
100+
}
101+
86102
public String getUser() {
87103
return this.user;
88104
}
@@ -132,8 +148,11 @@ public Packages getPackages() {
132148
}
133149

134150
String determineBrokerUrl() {
135-
if (this.brokerUrl != null) {
136-
return this.brokerUrl;
151+
if (this.getBrokerUrl() != null) {
152+
return this.getBrokerUrl();
153+
}
154+
if (this.isInMemory()) {
155+
return DEFAULT_EMBEDDED_BROKER_URL;
137156
}
138157
return DEFAULT_NETWORK_BROKER_URL;
139158
}

spring-boot-project/spring-boot-starters/spring-boot-starter-activemq/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dependencies {
88
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
99
api("org.springframework:spring-jms")
1010
api("org.apache.activemq:activemq-client")
11+
api("org.apache.activemq:activemq-broker")
1112
}

0 commit comments

Comments
 (0)