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
aa483984
Commit
aa483984
authored
Jul 16, 2015
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
1683d8a8
Closes gh-3475
parent
1683d8a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
42 deletions
+49
-42
RabbitAnnotationDrivenConfiguration.java
...toconfigure/amqp/RabbitAnnotationDrivenConfiguration.java
+5
-4
RabbitProperties.java
...ngframework/boot/autoconfigure/amqp/RabbitProperties.java
+19
-16
RabbitAutoConfigurationTests.java
...boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
+20
-22
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+5
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java
View file @
aa483984
...
...
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration;
* Configuration for Spring AMQP annotation driven endpoints.
*
* @author Stephane Nicoll
* @author Josh Thornhill
* @since 1.2.0
*/
@Configuration
...
...
@@ -43,8 +44,8 @@ class RabbitAnnotationDrivenConfiguration {
SimpleRabbitListenerContainerFactory
factory
=
new
SimpleRabbitListenerContainerFactory
();
factory
.
setConnectionFactory
(
connectionFactory
);
Listener
listenerConfig
=
config
.
getListener
();
if
(
listenerConfig
.
getAckMode
()
!=
null
)
{
factory
.
setAcknowledgeMode
(
listenerConfig
.
getAckMode
());
if
(
listenerConfig
.
getAck
nowledge
Mode
()
!=
null
)
{
factory
.
setAcknowledgeMode
(
listenerConfig
.
getAck
nowledge
Mode
());
}
if
(
listenerConfig
.
getConcurrency
()
!=
null
)
{
factory
.
setConcurrentConsumers
(
listenerConfig
.
getConcurrency
());
...
...
@@ -55,8 +56,8 @@ class RabbitAnnotationDrivenConfiguration {
if
(
listenerConfig
.
getPrefetch
()
!=
null
)
{
factory
.
setPrefetchCount
(
listenerConfig
.
getPrefetch
());
}
if
(
listenerConfig
.
getT
x
Size
()
!=
null
)
{
factory
.
setTxSize
(
listenerConfig
.
getT
x
Size
());
if
(
listenerConfig
.
getT
ransaction
Size
()
!=
null
)
{
factory
.
setTxSize
(
listenerConfig
.
getT
ransaction
Size
());
}
return
factory
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
View file @
aa483984
...
...
@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
* @author Dave Syer
* @author Stephane Nicoll
* @author Andy Wilkinson
* @author Josh Thornhill
*/
@ConfigurationProperties
(
prefix
=
"spring.rabbitmq"
)
public
class
RabbitProperties
{
...
...
@@ -187,7 +188,7 @@ public class RabbitProperties {
}
public
Listener
getListener
()
{
return
listener
;
return
this
.
listener
;
}
public
static
class
Ssl
{
...
...
@@ -287,7 +288,7 @@ public class RabbitProperties {
/**
* Acknowledge mode of container.
*/
private
AcknowledgeMode
ackMode
;
private
AcknowledgeMode
ack
nowledge
Mode
;
/**
* Minimum number of consumers.
...
...
@@ -300,25 +301,27 @@ public class RabbitProperties {
private
Integer
maxConcurrency
;
/**
* Message prefetch count.
* Number of messages to be handled in a single request. It should be greater than
* or equal to the transaction size (if used).
*/
private
Integer
prefetch
;
/**
* Number of messages in a transaction.
* Number of messages to be processed in a transaction. For best results it should
* be less than or equal to the prefetch count.
*/
private
Integer
t
x
Size
;
private
Integer
t
ransaction
Size
;
public
AcknowledgeMode
getAckMode
()
{
return
ack
Mode
;
public
AcknowledgeMode
getAck
nowledge
Mode
()
{
return
this
.
acknowledge
Mode
;
}
public
void
setAck
Mode
(
AcknowledgeMode
ack
Mode
)
{
this
.
ack
Mode
=
ack
Mode
;
public
void
setAck
nowledgeMode
(
AcknowledgeMode
acknowledge
Mode
)
{
this
.
ack
nowledgeMode
=
acknowledge
Mode
;
}
public
Integer
getConcurrency
()
{
return
concurrency
;
return
this
.
concurrency
;
}
public
void
setConcurrency
(
Integer
concurrency
)
{
...
...
@@ -326,7 +329,7 @@ public class RabbitProperties {
}
public
Integer
getMaxConcurrency
()
{
return
maxConcurrency
;
return
this
.
maxConcurrency
;
}
public
void
setMaxConcurrency
(
Integer
maxConcurrency
)
{
...
...
@@ -334,19 +337,19 @@ public class RabbitProperties {
}
public
Integer
getPrefetch
()
{
return
prefetch
;
return
this
.
prefetch
;
}
public
void
setPrefetch
(
Integer
prefetch
)
{
this
.
prefetch
=
prefetch
;
}
public
Integer
getT
x
Size
()
{
return
t
x
Size
;
public
Integer
getT
ransaction
Size
()
{
return
t
his
.
transaction
Size
;
}
public
void
setT
xSize
(
Integer
tx
Size
)
{
this
.
t
xSize
=
tx
Size
;
public
void
setT
ransactionSize
(
Integer
transaction
Size
)
{
this
.
t
ransactionSize
=
transaction
Size
;
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
View file @
aa483984
...
...
@@ -187,6 +187,26 @@ public class RabbitAutoConfigurationTests {
verify
(
rabbitListenerContainerFactory
).
setTxSize
(
10
);
}
@Test
public
void
testRabbitListenerContainerFactoryWithCustomSettings
()
{
load
(
TestConfiguration
.
class
,
"spring.rabbitmq.listener.acknowledgeMode:manual"
,
"spring.rabbitmq.listener.concurrency:5"
,
"spring.rabbitmq.listener.maxConcurrency:10"
,
"spring.rabbitmq.listener.prefetch=40"
,
"spring.rabbitmq.listener.transactionSize:20"
);
SimpleRabbitListenerContainerFactory
rabbitListenerContainerFactory
=
this
.
context
.
getBean
(
"rabbitListenerContainerFactory"
,
SimpleRabbitListenerContainerFactory
.
class
);
DirectFieldAccessor
dfa
=
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
);
assertEquals
(
AcknowledgeMode
.
MANUAL
,
dfa
.
getPropertyValue
(
"acknowledgeMode"
));
assertEquals
(
5
,
dfa
.
getPropertyValue
(
"concurrentConsumers"
));
assertEquals
(
10
,
dfa
.
getPropertyValue
(
"maxConcurrentConsumers"
));
assertEquals
(
40
,
dfa
.
getPropertyValue
(
"prefetchCount"
));
assertEquals
(
20
,
dfa
.
getPropertyValue
(
"txSize"
));
}
@Test
public
void
enableRabbitAutomatically
()
throws
Exception
{
load
(
NoEnableRabbitConfiguration
.
class
);
...
...
@@ -230,28 +250,6 @@ public class RabbitAutoConfigurationTests {
"spring.rabbitmq.ssl.trustStorePassword=secret"
);
}
@Test
public
void
testRabbitListenerContainerFactoryOverrides
()
{
load
(
TestConfiguration
.
class
,
"spring.rabbitmq.listener.prefetch:20"
,
"spring.rabbitmq.listener.ackMode:MANUAL"
,
"spring.rabbitmq.listener.concurrency:10"
,
"spring.rabbitmq.listener.maxConcurrency:10"
,
"spring.rabbitmq.listener.txSize:20"
);
SimpleRabbitListenerContainerFactory
rabbitListenerContainerFactory
=
this
.
context
.
getBean
(
"rabbitListenerContainerFactory"
,
SimpleRabbitListenerContainerFactory
.
class
);
assertEquals
(
new
Integer
(
20
),
(
Integer
)
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
).
getPropertyValue
(
"prefetchCount"
));
assertEquals
(
AcknowledgeMode
.
MANUAL
,
(
AcknowledgeMode
)
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
).
getPropertyValue
(
"acknowledgeMode"
));
assertEquals
(
new
Integer
(
10
),
(
Integer
)
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
).
getPropertyValue
(
"concurrentConsumers"
));
assertEquals
(
new
Integer
(
10
),
(
Integer
)
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
).
getPropertyValue
(
"maxConcurrentConsumers"
));
assertEquals
(
new
Integer
(
20
),
(
Integer
)
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
).
getPropertyValue
(
"txSize"
));
}
private
com
.
rabbitmq
.
client
.
ConnectionFactory
getTargetConnectionFactory
()
{
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
aa483984
...
...
@@ -469,6 +469,11 @@ content into your application; rather pick only the properties that you need.
spring.rabbitmq.port= # connection port
spring.rabbitmq.password= # login password
spring.rabbitmq.requested-heartbeat= # requested heartbeat timeout, in seconds; zero for none
spring.rabbitmq.listener.acknowledge-mode= # acknowledge mode of container
spring.rabbitmq.listener.concurrency= # minimum number of consumers
spring.rabbitmq.listener.max-concurrency= # maximum number of consumers
spring.rabbitmq.listener.prefetch= # number of messages to be handled in a single request
spring.rabbitmq.listener.transaction-size= # number of messages to be processed in a transaction
spring.rabbitmq.ssl.enabled=false # enable SSL support
spring.rabbitmq.ssl.key-store= # path to the key store that holds the SSL certificate
spring.rabbitmq.ssl.key-store-password= # password used to access the key store
...
...
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