Skip to content

Commit 1c10861

Browse files
committed
Revised documentation on AUTO_ACKNOWLEDGE behavior
Issue: SPR-12705 (cherry picked from commit 91c47a9)
1 parent 1f9bc50 commit 1c10861

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,8 +54,13 @@
5454
* <p>The listener container offers the following message acknowledgment options:
5555
* <ul>
5656
* <li>"sessionAcknowledgeMode" set to "AUTO_ACKNOWLEDGE" (default):
57-
* Automatic message acknowledgment <i>before</i> listener execution;
58-
* no redelivery in case of exception thrown.
57+
* This mode is container-dependent: For {@link DefaultMessageListenerContainer},
58+
* it means automatic message acknowledgment <i>before</i> listener execution, with
59+
* no redelivery in case of an exception. For {@link SimpleMessageListenerContainer},
60+
* it means automatic message acknowledgment <i>after</i> listener execution, with
61+
* redelivery in case of an exception thrown, as defined by the JMS specification.
62+
* In order to consistently achieve the latter behavior with any container variant,
63+
* consider setting "sessionTransacted" to "true" instead.
5964
* <li>"sessionAcknowledgeMode" set to "CLIENT_ACKNOWLEDGE":
6065
* Automatic message acknowledgment <i>after</i> successful listener execution;
6166
* no redelivery in case of exception thrown.

spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -104,9 +104,11 @@
104104
* <p><b>It is strongly recommended to either set {@link #setSessionTransacted
105105
* "sessionTransacted"} to "true" or specify an external {@link #setTransactionManager
106106
* "transactionManager"}.</b> See the {@link AbstractMessageListenerContainer}
107-
* javadoc for details on acknowledge modes and native transaction options,
108-
* as well as the {@link AbstractPollingMessageListenerContainer} javadoc
109-
* for details on configuring an external transaction manager.
107+
* javadoc for details on acknowledge modes and native transaction options, as
108+
* well as the {@link AbstractPollingMessageListenerContainer} javadoc for details
109+
* on configuring an external transaction manager. Note that for the default
110+
* "AUTO_ACKNOWLEDGE" mode, this container applies automatic message acknowledgment
111+
* before listener execution, with no redelivery in case of an exception.
110112
*
111113
* @author Juergen Hoeller
112114
* @since 2.0

spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,10 @@
4545
* on the JMS provider: Not even the ServerSessionPool facility is required.
4646
*
4747
* <p>See the {@link AbstractMessageListenerContainer} javadoc for details
48-
* on acknowledge modes and transaction options.
48+
* on acknowledge modes and transaction options. Note that this container
49+
* exposes standard JMS behavior for the default "AUTO_ACKNOWLEDGE" mode:
50+
* that is, automatic message acknowledgment after listener execution,
51+
* with redelivery in case of an exception thrown.
4952
*
5053
* <p>For a different style of MessageListener handling, through looped
5154
* {@code MessageConsumer.receive()} calls that also allow for

0 commit comments

Comments
 (0)