Also cache and compare session to avoid stale Destination
@@ -78,6 +78,12 @@ public class JMSConfiguration {
*/
private String replyToDestination;
private volatile Destination replyToDestinationDest;
+
+ /**
+ * Session that was used to cache the replyToDestinationDest
+ */
+ private volatile Session replyDestinationSession;
+
private String messageType = JMSConstants.TEXT_MESSAGE_TYPE;
private boolean pubSubDomain;
private boolean replyPubSubDomain;
@@ -97,8 +103,6 @@ public class JMSConfiguration {
private String targetService;
private String requestURI;
-
-
public void ensureProperlyConfigured() {
ConnectionFactory cf = getConnectionFactory();
if (cf == null) {
@@ -464,19 +468,17 @@ public class JMSConfiguration {
}
public Destination getReplyDestination(Session session) throws JMSException {
- Destination result = replyDestinationDest;
- if (result == null) {
+ if (this.replyDestinationDest == null || this.replyDestinationSession == null) {
synchronized (this) {
- result = replyDestinationDest;
- if (result == null) {
- result = replyDestination == null
+ if (this.replyDestinationDest == null || this.replyDestinationSession == null) {
+ this.replyDestinationDest = replyDestination == null
? session.createTemporaryQueue()
: destinationResolver.resolveDestinationName(session, replyDestination, replyPubSubDomain);
- replyDestinationDest = result;
+ this.replyDestinationSession = session;
}
}
}
- return result;
+ return this.replyDestinationDest;
}
public Destination getTargetDestination(Session session) throws JMSException {
