Skip to content

Commit c1a9e34

Browse files
committed
Revised documentation on AUTO_ACKNOWLEDGE behavior
Issue: SPR-12705
1 parent 594a14a commit c1a9e34

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.
@@ -60,8 +60,13 @@
6060
* <p>The listener container offers the following message acknowledgment options:
6161
* <ul>
6262
* <li>"sessionAcknowledgeMode" set to "AUTO_ACKNOWLEDGE" (default):
63-
* Automatic message acknowledgment <i>before</i> listener execution;
64-
* no redelivery in case of exception thrown.
63+
* This mode is container-dependent: For {@link DefaultMessageListenerContainer},
64+
* it means automatic message acknowledgment <i>before</i> listener execution, with
65+
* no redelivery in case of an exception. For {@link SimpleMessageListenerContainer},
66+
* it means automatic message acknowledgment <i>after</i> listener execution, with
67+
* redelivery in case of an exception thrown, as defined by the JMS specification.
68+
* In order to consistently achieve the latter behavior with any container variant,
69+
* consider setting "sessionTransacted" to "true" instead.
6570
* <li>"sessionAcknowledgeMode" set to "CLIENT_ACKNOWLEDGE":
6671
* Automatic message acknowledgment <i>after</i> successful listener execution;
6772
* 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-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.
@@ -107,9 +107,11 @@
107107
* <p><b>It is strongly recommended to either set {@link #setSessionTransacted
108108
* "sessionTransacted"} to "true" or specify an external {@link #setTransactionManager
109109
* "transactionManager"}.</b> See the {@link AbstractMessageListenerContainer}
110-
* javadoc for details on acknowledge modes and native transaction options,
111-
* as well as the {@link AbstractPollingMessageListenerContainer} javadoc
112-
* for details on configuring an external transaction manager.
110+
* javadoc for details on acknowledge modes and native transaction options, as
111+
* well as the {@link AbstractPollingMessageListenerContainer} javadoc for details
112+
* on configuring an external transaction manager. Note that for the default
113+
* "AUTO_ACKNOWLEDGE" mode, this container applies automatic message acknowledgment
114+
* before listener execution, with no redelivery in case of an exception.
113115
*
114116
* @author Juergen Hoeller
115117
* @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-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.
@@ -44,7 +44,10 @@
4444
* on the JMS provider: Not even the ServerSessionPool facility is required.
4545
*
4646
* <p>See the {@link AbstractMessageListenerContainer} javadoc for details
47-
* on acknowledge modes and transaction options.
47+
* on acknowledge modes and transaction options. Note that this container
48+
* exposes standard JMS behavior for the default "AUTO_ACKNOWLEDGE" mode:
49+
* that is, automatic message acknowledgment after listener execution,
50+
* with redelivery in case of an exception thrown.
4851
*
4952
* <p>For a different style of MessageListener handling, through looped
5053
* {@code MessageConsumer.receive()} calls that also allow for

0 commit comments

Comments
 (0)