Skip to content

Commit e72b0a0

Browse files
committed
Document limitations for MessageProducer/Consumer caching with WebLogic JMS
Closes gh-28500
1 parent f8b41c1 commit e72b0a0

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -49,8 +49,8 @@
4949
import org.springframework.util.ObjectUtils;
5050

5151
/**
52-
* {@link SingleConnectionFactory} subclass that adds {@link javax.jms.Session}
53-
* caching as well {@link javax.jms.MessageProducer} caching. This ConnectionFactory
52+
* {@link SingleConnectionFactory} subclass that adds {@link Session} caching as well as
53+
* {@link MessageProducer} and {@link MessageConsumer} caching. This ConnectionFactory
5454
* also switches the {@link #setReconnectOnException "reconnectOnException" property}
5555
* to "true" by default, allowing for automatic recovery of the underlying Connection.
5656
*
@@ -82,8 +82,19 @@
8282
* Re-registering a durable consumer for the same subscription on the same
8383
* Session handle is not supported; close and reobtain a cached Session first.
8484
*
85+
* <p>Last but not least, MessageProducers and MessageConsumers for temporary
86+
* queues and topics (TemporaryQueue/TemporaryTopic) will never be cached.
87+
* Unfortunately, WebLogic JMS happens to implement the temporary queue/topic
88+
* interfaces on its regular destination implementation, mis-indicating that
89+
* none of its destinations can be cached. Please use a different connection
90+
* pool/cache on WebLogic, or customize this class for WebLogic purposes.
91+
*
8592
* @author Juergen Hoeller
8693
* @since 2.5.3
94+
* @see Connection
95+
* @see Session
96+
* @see MessageProducer
97+
* @see MessageConsumer
8798
*/
8899
public class CachingConnectionFactory extends SingleConnectionFactory {
89100

src/docs/asciidoc/integration.adoc

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,17 +1605,26 @@ takes a reference to a standard `ConnectionFactory` that would typically come fr
16051605
===== Using `CachingConnectionFactory`
16061606

16071607
The `CachingConnectionFactory` extends the functionality of `SingleConnectionFactory`
1608-
and adds the caching of `Session`, `MessageProducer`, and `MessageConsumer` instances. The initial
1609-
cache size is set to `1`. You can use the `sessionCacheSize` property to increase the number of
1610-
cached sessions. Note that the number of actual cached sessions is more than that
1611-
number, as sessions are cached based on their acknowledgment mode, so there can be up to
1612-
four cached session instances (one for each
1613-
acknowledgment mode) when `sessionCacheSize` is set to one. `MessageProducer` and `MessageConsumer` instances are cached within their
1614-
owning session and also take into account the unique properties of the producers and
1615-
consumers when caching. MessageProducers are cached based on their destination.
1616-
MessageConsumers are cached based on a key composed of the destination, selector,
1608+
and adds the caching of `Session`, `MessageProducer`, and `MessageConsumer` instances.
1609+
The initial cache size is set to `1`. You can use the `sessionCacheSize` property to
1610+
increase the number of cached sessions. Note that the number of actual cached sessions
1611+
is more than that number, as sessions are cached based on their acknowledgment mode,
1612+
so there can be up to four cached session instances (one for each acknowledgment mode)
1613+
when `sessionCacheSize` is set to one. `MessageProducer` and `MessageConsumer` instances
1614+
are cached within their owning session and also take into account the unique properties
1615+
of the producers and consumers when caching. MessageProducers are cached based on their
1616+
destination. MessageConsumers are cached based on a key composed of the destination, selector,
16171617
noLocal delivery flag, and the durable subscription name (if creating durable consumers).
16181618

1619+
[NOTE]
1620+
====
1621+
MessageProducers and MessageConsumers for temporary queues and topics
1622+
(TemporaryQueue/TemporaryTopic) will never be cached. Unfortunately, WebLogic JMS happens
1623+
to implement the temporary queue/topic interfaces on its regular destination implementation,
1624+
mis-indicating that none of its destinations can be cached. Please use a different connection
1625+
pool/cache on WebLogic, or customize `CachingConnectionFactory` for WebLogic purposes.
1626+
====
1627+
16191628

16201629
[[jms-destinations]]
16211630
==== Destination Management

0 commit comments

Comments
 (0)