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
4e31d204
Commit
4e31d204
authored
Nov 10, 2017
by
Arlo O'Keeffe
Committed by
Stephane Nicoll
Dec 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make RabbitTemplate exchange and routingKey configurable
See gh-10978
parent
4eda29a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
0 deletions
+57
-0
RabbitAutoConfiguration.java
...work/boot/autoconfigure/amqp/RabbitAutoConfiguration.java
+3
-0
RabbitProperties.java
...ngframework/boot/autoconfigure/amqp/RabbitProperties.java
+39
-0
RabbitAutoConfigurationTests.java
...boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
+15
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java
View file @
4e31d204
...
@@ -188,6 +188,9 @@ public class RabbitAutoConfiguration {
...
@@ -188,6 +188,9 @@ public class RabbitAutoConfiguration {
if
(
templateProperties
.
getReplyTimeout
()
!=
null
)
{
if
(
templateProperties
.
getReplyTimeout
()
!=
null
)
{
rabbitTemplate
.
setReplyTimeout
(
templateProperties
.
getReplyTimeout
());
rabbitTemplate
.
setReplyTimeout
(
templateProperties
.
getReplyTimeout
());
}
}
rabbitTemplate
.
setExchange
(
templateProperties
.
getExchange
());
rabbitTemplate
.
setRoutingKey
(
templateProperties
.
getRoutingKey
());
rabbitTemplate
.
setChannelTransacted
(
templateProperties
.
isChannelTransacted
());
return
rabbitTemplate
;
return
rabbitTemplate
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
View file @
4e31d204
...
@@ -703,6 +703,21 @@ public class RabbitProperties {
...
@@ -703,6 +703,21 @@ public class RabbitProperties {
*/
*/
private
Long
replyTimeout
;
private
Long
replyTimeout
;
/**
* Name of the default exchange to use for send operations.
*/
private
String
exchange
=
""
;
/**
* Value of a default routing key to use for send operations.
*/
private
String
routingKey
=
""
;
/**
* Enable transactional channels.
*/
private
boolean
channelTransacted
;
public
Retry
getRetry
()
{
public
Retry
getRetry
()
{
return
this
.
retry
;
return
this
.
retry
;
}
}
...
@@ -731,6 +746,30 @@ public class RabbitProperties {
...
@@ -731,6 +746,30 @@ public class RabbitProperties {
this
.
replyTimeout
=
replyTimeout
;
this
.
replyTimeout
=
replyTimeout
;
}
}
public
String
getExchange
()
{
return
this
.
exchange
;
}
public
void
setExchange
(
String
exchange
)
{
this
.
exchange
=
exchange
;
}
public
String
getRoutingKey
()
{
return
this
.
routingKey
;
}
public
void
setRoutingKey
(
String
routingKey
)
{
this
.
routingKey
=
routingKey
;
}
public
boolean
isChannelTransacted
()
{
return
this
.
channelTransacted
;
}
public
void
setChannelTransacted
(
boolean
channelTransacted
)
{
this
.
channelTransacted
=
channelTransacted
;
}
}
}
public
static
class
Retry
{
public
static
class
Retry
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
View file @
4e31d204
...
@@ -103,6 +103,21 @@ public class RabbitAutoConfigurationTests {
...
@@ -103,6 +103,21 @@ public class RabbitAutoConfigurationTests {
});
});
}
}
@Test
public
void
testDefaultRabbitTemplateConfiguration
()
{
this
.
contextRunner
.
withUserConfiguration
(
TestConfiguration
.
class
)
.
run
((
context
)
->
{
RabbitTemplate
rabbitTemplate
=
context
.
getBean
(
RabbitTemplate
.
class
);
RabbitTemplate
defaultRabbitTemplate
=
new
RabbitTemplate
();
assertThat
(
rabbitTemplate
.
getRoutingKey
())
.
isEqualTo
(
defaultRabbitTemplate
.
getRoutingKey
());
assertThat
(
rabbitTemplate
.
getExchange
())
.
isEqualTo
(
defaultRabbitTemplate
.
getExchange
());
assertThat
(
rabbitTemplate
.
isChannelTransacted
())
.
isEqualTo
(
defaultRabbitTemplate
.
isChannelTransacted
());
});
}
@Test
@Test
public
void
testConnectionFactoryWithOverrides
()
{
public
void
testConnectionFactoryWithOverrides
()
{
this
.
contextRunner
.
withUserConfiguration
(
TestConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
TestConfiguration
.
class
)
...
...
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