@@ -1797,6 +1797,13 @@ the message getting redelivered. Alternatively, consider using 'CLIENT_ACKNOWLED
1797
1797
which provides redelivery in case of an exception as well but does not use transacted
1798
1798
Sessions and therefore does not include any other Session operations (such as sending
1799
1799
response messages) in the transaction protocol.
1800
+
1801
+ **The default 'AUTO_ACKNOWLEDGE' mode does not provide proper reliability guarantees.**
1802
+ Messages may get lost when listener execution fails (since the provider will automatically
1803
+ acknowledge each message after listener invocation, with no exceptions to be propagated to
1804
+ the provider) or when the listener container shuts down (this may be configured through
1805
+ the 'acceptMessagesWhileStopping' flag). Make sure to use transacted sessions in case of
1806
+ reliability needs, e.g. for reliable queue handling and durable topic subscriptions.
1800
1807
====
1801
1808
1802
1809
[[jms-mdp-default]]
@@ -1834,6 +1841,13 @@ alternative: wrapping your entire processing with an XA transaction (through con
1834
1841
your `DefaultMessageListenerContainer` with an `JtaTransactionManager`), covering the
1835
1842
reception of the JMS message as well as the execution of the business logic in your
1836
1843
message listener (including database operations etc).
1844
+
1845
+ **The default 'AUTO_ACKNOWLEDGE' mode does not provide proper reliability guarantees.**
1846
+ Messages may get lost when listener execution fails (since the provider will automatically
1847
+ acknowledge each message before listener invocation) or when the listener container shuts
1848
+ down (this may be configured through the 'acceptMessagesWhileStopping' flag). Make sure
1849
+ to use transacted sessions in case of reliability needs, e.g. for reliable queue handling
1850
+ and durable topic subscriptions.
1837
1851
====
1838
1852
1839
1853
@@ -2065,7 +2079,6 @@ Below is a simple implementation of an MDP:
2065
2079
throw new IllegalArgumentException("Message must be of type TextMessage");
2066
2080
}
2067
2081
}
2068
-
2069
2082
}
2070
2083
----
2071
2084
@@ -2108,7 +2121,6 @@ handling method with access to the JMS `Session` from which the `Message` was re
2108
2121
public interface SessionAwareMessageListener {
2109
2122
2110
2123
void onMessage(Message message, Session session) throws JMSException;
2111
-
2112
2124
}
2113
2125
----
2114
2126
@@ -2153,7 +2165,6 @@ various `Message` types that they can receive and handle.
2153
2165
void handleMessage(byte[] message);
2154
2166
2155
2167
void handleMessage(Serializable message);
2156
-
2157
2168
}
2158
2169
----
2159
2170
@@ -2200,7 +2211,6 @@ also how the `'receive(..)'` method is strongly typed to receive and respond onl
2200
2211
public interface TextMessageDelegate {
2201
2212
2202
2213
void receive(TextMessage message);
2203
-
2204
2214
}
2205
2215
----
2206
2216
@@ -2242,7 +2252,6 @@ non-void value. Consider the interface and class:
2242
2252
2243
2253
// notice the return type...
2244
2254
String receive(TextMessage message);
2245
-
2246
2255
}
2247
2256
----
2248
2257
@@ -2469,10 +2478,10 @@ your `@Configuration` classes.
2469
2478
2470
2479
@Bean
2471
2480
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
2472
- DefaultJmsListenerContainerFactory factory =
2473
- new DefaultJmsListenerContainerFactory();
2481
+ DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
2474
2482
factory.setConnectionFactory(connectionFactory());
2475
2483
factory.setDestinationResolver(destinationResolver());
2484
+ factory.setSessionTransacted(true);
2476
2485
factory.setConcurrency("3-10");
2477
2486
return factory;
2478
2487
}
@@ -2501,6 +2510,7 @@ element.
2501
2510
class="org.springframework.jms.config.DefaultJmsListenerContainerFactory">
2502
2511
<property name="connectionFactory" ref="connectionFactory"/>
2503
2512
<property name="destinationResolver" ref="destinationResolver"/>
2513
+ <property name="sessionTransacted" value="true"/>
2504
2514
<property name="concurrency" value="3-10"/>
2505
2515
</bean>
2506
2516
----
@@ -2696,8 +2706,7 @@ the time to live, you can configure the `JmsListenerContainerFactory` accordingl
2696
2706
2697
2707
@Bean
2698
2708
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
2699
- DefaultJmsListenerContainerFactory factory =
2700
- new DefaultJmsListenerContainerFactory();
2709
+ DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
2701
2710
factory.setConnectionFactory(connectionFactory());
2702
2711
QosSettings replyQosSettings = new ReplyQosSettings();
2703
2712
replyQosSettings.setPriority(2);
0 commit comments