Skip to content

Commit

Permalink
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 19, 2024
1 parent a4c1b40 commit 2fb6829
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 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-jakarta")
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-jakarta")
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 @@ -44,6 +44,12 @@ public class ActiveMQProperties {
*/
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 +89,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
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Spring Boot also auto-configures the necessary infrastructure to send and receiv


[[messaging.jms.activemq]]
=== ActiveMQ "Classic" Support
When https://activemq.apache.org/components/classic[ActiveMQ "Classic"] is available on the classpath, Spring Boot can configure a `ConnectionFactory`.
=== ActiveMQ Classic Support
When https://activemq.apache.org/components/classic[ActiveMQ Classic] is available on the classpath, Spring Boot can configure a `ConnectionFactory`.

NOTE: If you use `spring-boot-starter-activemq`, the necessary dependencies to connect to an ActiveMQ "Classic" instance are provided, as is the Spring infrastructure to integrate with JMS.

ActiveMQ "Classic" configuration is controlled by external configuration properties in `+spring.activemq.*+`.
By default, ActiveMQ "Classic" is auto-configured to use the https://activemq.apache.org/tcp-transport-reference[TCP transport], connecting by default to `tcp://localhost:61616`. The following example shows how to change the default broker URL:
ActiveMQ Classic configuration is controlled by external configuration properties in `+spring.activemq.*+`.
By default, ActiveMQ Classic is auto-configured to use the https://activemq.apache.org/tcp-transport-reference[TCP transport], connecting by default to `tcp://localhost:61616`. The following example shows how to change the default broker URL:

[source,yaml,indent=0,configprops,configblocks]
----
Expand Down Expand Up @@ -49,7 +49,7 @@ If you'd rather use native pooling, you can do so by adding a dependency to `org
TIP: See {spring-boot-autoconfigure-module-code}/jms/activemq/ActiveMQProperties.java[`ActiveMQProperties`] for more of the supported options.
You can also register an arbitrary number of beans that implement `ActiveMQConnectionFactoryCustomizer` for more advanced customizations.

By default, ActiveMQ "Classic" creates a destination if it does not yet exist so that destinations are resolved against their provided names.
By default, ActiveMQ Classic creates a destination if it does not yet exist so that destinations are resolved against their provided names.



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-jakarta")
api("org.apache.activemq:activemq-broker")
}

0 comments on commit 2fb6829

Please sign in to comment.