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
0fedb24c
Commit
0fedb24c
authored
Oct 29, 2019
by
Mark Pollack
Committed by
Stephane Nicoll
Nov 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support amqps:// URIs in spring.rabbitmq.addresses
See gh-18808 Co-Authored-By:
Bryan Kelly
<
xyloman@gmail.com
>
parent
ed50bf24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
RabbitProperties.java
...ngframework/boot/autoconfigure/amqp/RabbitProperties.java
+16
-1
RabbitPropertiesTests.java
...mework/boot/autoconfigure/amqp/RabbitPropertiesTests.java
+7
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
View file @
0fedb24c
...
...
@@ -937,6 +937,10 @@ public class RabbitProperties {
private
static
final
int
DEFAULT_PORT
=
5672
;
private
static
final
String
PREFIX_AMQP_SECURE
=
"amqps://"
;
private
static
final
int
DEFAULT_PORT_SECURE
=
5671
;
private
String
host
;
private
int
port
;
...
...
@@ -947,6 +951,8 @@ public class RabbitProperties {
private
String
virtualHost
;
private
boolean
isSecureConnection
;
private
Address
(
String
input
)
{
input
=
input
.
trim
();
input
=
trimPrefix
(
input
);
...
...
@@ -956,6 +962,10 @@ public class RabbitProperties {
}
private
String
trimPrefix
(
String
input
)
{
if
(
input
.
startsWith
(
PREFIX_AMQP_SECURE
))
{
this
.
isSecureConnection
=
true
;
return
input
.
substring
(
PREFIX_AMQP_SECURE
.
length
());
}
if
(
input
.
startsWith
(
PREFIX_AMQP
))
{
input
=
input
.
substring
(
PREFIX_AMQP
.
length
());
}
...
...
@@ -992,7 +1002,12 @@ public class RabbitProperties {
int
portIndex
=
input
.
indexOf
(
':'
);
if
(
portIndex
==
-
1
)
{
this
.
host
=
input
;
this
.
port
=
DEFAULT_PORT
;
if
(
this
.
isSecureConnection
)
{
this
.
port
=
DEFAULT_PORT_SECURE
;
}
else
{
this
.
port
=
DEFAULT_PORT
;
}
}
else
{
this
.
host
=
input
.
substring
(
0
,
portIndex
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitPropertiesTests.java
View file @
0fedb24c
...
...
@@ -70,6 +70,13 @@ public class RabbitPropertiesTests {
assertThat
(
this
.
properties
.
getPort
()).
isEqualTo
(
1234
);
}
@Test
void
usingSecuredConnections
()
{
this
.
properties
.
setAddresses
(
"amqps://root:password@otherhost,amqps://root:password2@otherhost2"
);
assertThat
(
this
.
properties
.
determinePort
()).
isEqualTo
(
5671
);
assertThat
(
this
.
properties
.
determineAddresses
()).
isEqualTo
(
"otherhost:5671,otherhost2:5671"
);
}
@Test
public
void
determinePortReturnsPortOfFirstAddress
()
{
this
.
properties
.
setAddresses
(
"rabbit1.example.com:1234,rabbit2.example.com:2345"
);
...
...
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