Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
0d8bde58
Commit
0d8bde58
authored
Sep 30, 2014
by
Henryk Konsek
Committed by
Phillip Webb
Oct 08, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ActiveMQ MQTT connection URL auto-detection
Fixes gh-1638
parent
4c51aa8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
ActiveMQConnectionFactoryFactory.java
...figure/jms/activemq/ActiveMQConnectionFactoryFactory.java
+20
-0
ActiveMQProperties.java
...k/boot/autoconfigure/jms/activemq/ActiveMQProperties.java
+10
-0
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java
View file @
0d8bde58
...
@@ -16,8 +16,13 @@
...
@@ -16,8 +16,13 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
jms
.
activemq
;
package
org
.
springframework
.
boot
.
autoconfigure
.
jms
.
activemq
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.apache.activemq.ActiveMQConnectionFactory
;
import
org.apache.activemq.ActiveMQConnectionFactory
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
/**
/**
...
@@ -33,6 +38,14 @@ class ActiveMQConnectionFactoryFactory {
...
@@ -33,6 +38,14 @@ class ActiveMQConnectionFactoryFactory {
private
static
final
String
DEFAULT_NETWORK_BROKER_URL
=
"tcp://localhost:61616"
;
private
static
final
String
DEFAULT_NETWORK_BROKER_URL
=
"tcp://localhost:61616"
;
private
static
final
Map
<
String
,
String
>
CLASS_BASED_BROKER_URLS
;
static
{
Map
<
String
,
String
>
map
=
new
LinkedHashMap
<
String
,
String
>();
map
.
put
(
"org.apache.activemq.transport.mqtt.MQTTTransport"
,
"mqtt://localhost:1883"
);
CLASS_BASED_BROKER_URLS
=
Collections
.
unmodifiableMap
(
map
);
}
private
final
ActiveMQProperties
properties
;
private
final
ActiveMQProperties
properties
;
public
ActiveMQConnectionFactoryFactory
(
ActiveMQProperties
properties
)
{
public
ActiveMQConnectionFactoryFactory
(
ActiveMQProperties
properties
)
{
...
@@ -67,6 +80,13 @@ class ActiveMQConnectionFactoryFactory {
...
@@ -67,6 +80,13 @@ class ActiveMQConnectionFactoryFactory {
if
(
this
.
properties
.
getBrokerUrl
()
!=
null
)
{
if
(
this
.
properties
.
getBrokerUrl
()
!=
null
)
{
return
this
.
properties
.
getBrokerUrl
();
return
this
.
properties
.
getBrokerUrl
();
}
}
if
(
this
.
properties
.
isAutodetectConnectionUrl
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
CLASS_BASED_BROKER_URLS
.
entrySet
())
{
if
(
ClassUtils
.
isPresent
(
entry
.
getKey
(),
null
))
{
return
entry
.
getValue
();
}
}
}
if
(
this
.
properties
.
isInMemory
())
{
if
(
this
.
properties
.
isInMemory
())
{
return
DEFAULT_EMBEDDED_BROKER_URL
;
return
DEFAULT_EMBEDDED_BROKER_URL
;
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQProperties.java
View file @
0d8bde58
...
@@ -29,6 +29,8 @@ public class ActiveMQProperties {
...
@@ -29,6 +29,8 @@ public class ActiveMQProperties {
private
String
brokerUrl
;
private
String
brokerUrl
;
private
boolean
autodetectConnectionUrl
=
true
;
private
boolean
inMemory
=
true
;
private
boolean
inMemory
=
true
;
private
boolean
pooled
;
private
boolean
pooled
;
...
@@ -45,6 +47,14 @@ public class ActiveMQProperties {
...
@@ -45,6 +47,14 @@ public class ActiveMQProperties {
this
.
brokerUrl
=
brokerUrl
;
this
.
brokerUrl
=
brokerUrl
;
}
}
public
boolean
isAutodetectConnectionUrl
()
{
return
this
.
autodetectConnectionUrl
;
}
public
void
setAutodetectConnectionUrl
(
boolean
autodetectConnectionUrl
)
{
this
.
autodetectConnectionUrl
=
autodetectConnectionUrl
;
}
/**
/**
* Specify if the default broker url should be in memory. Ignored if an explicit
* Specify if the default broker url should be in memory. Ignored if an explicit
* broker has been specified.
* broker has been specified.
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
0d8bde58
...
@@ -284,6 +284,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -284,6 +284,7 @@ content into your application; rather pick only the properties that you need.
spring.activemq.broker-url=tcp://localhost:61616 # connection URL
spring.activemq.broker-url=tcp://localhost:61616 # connection URL
spring.activemq.user=
spring.activemq.user=
spring.activemq.password=
spring.activemq.password=
spring.activemq.autodetect-connection-url=true # attempt to guess URL based on classpath
spring.activemq.in-memory=true # broker kind to create if no broker-url is specified
spring.activemq.in-memory=true # broker kind to create if no broker-url is specified
spring.activemq.pooled=false
spring.activemq.pooled=false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment