Skip to content

Commit

Permalink
WIP: Reinstate support for auto-configuring an embedded ActiveMQ broker
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrpav committed Mar 20, 2024
1 parent 558d811 commit 0024927
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dependencies {
optional("jakarta.servlet:jakarta.servlet-api")
optional("javax.cache:cache-api")
optional("org.apache.activemq:activemq-client")
optional("org.apache.activemq:activemq-broker")
optional("org.apache.commons:commons-dbcp2") {
exclude group: "commons-logging", module: "commons-logging"
}
Expand Down
1 change: 1 addition & 0 deletions spring-boot-project/spring-boot-autoconfigure/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies {
optional("javax.cache:cache-api")
optional("javax.money:money-api")
optional("org.apache.activemq:activemq-client")
optional("org.apache.activemq:activemq-broker")
optional("org.apache.activemq:artemis-jakarta-client") {
exclude group: "commons-logging", module: "commons-logging"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
@ConfigurationProperties(prefix = "spring.activemq")
public class ActiveMQProperties {

private static final String DEFAULT_EMBEDDED_BROKER_URL = "vm://localhost?broker.persistent=false";

private static final String DEFAULT_NETWORK_BROKER_URL = "tcp://localhost:61616";

/**
* URL of the ActiveMQ broker. Auto-generated by default.
*/
private String brokerUrl;

/**
* Whether the default broker URL should be in memory. Ignored if an explicit broker
* has been specified.
*/
private boolean inMemory = true;

/**
* Login user of the broker.
*/
Expand Down Expand Up @@ -83,6 +91,14 @@ public void setBrokerUrl(String brokerUrl) {
this.brokerUrl = brokerUrl;
}

public boolean isInMemory() {
return this.inMemory;
}

public void setInMemory(boolean inMemory) {
this.inMemory = inMemory;
}

public String getUser() {
return this.user;
}
Expand Down Expand Up @@ -132,8 +148,11 @@ public Packages getPackages() {
}

String determineBrokerUrl() {
if (this.brokerUrl != null) {
return this.brokerUrl;
if (this.getBrokerUrl() != null) {
return this.getBrokerUrl();
}
if (this.isInMemory()) {
return DEFAULT_EMBEDDED_BROKER_URL;
}
return DEFAULT_NETWORK_BROKER_URL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dependencies {
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api("org.springframework:spring-jms")
api("org.apache.activemq:activemq-client")
api("org.apache.activemq:activemq-broker")
}

0 comments on commit 0024927

Please sign in to comment.