From b91e989ad4eb99999fc16944f37509b6bec06901 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Jan 2012 17:48:40 +0100 Subject: [PATCH] JMS CachingConnectionFactory never caches consumers for temporary queues and topics --- .../jms/connection/CachingConnectionFactory.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/org.springframework.jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java b/org.springframework.jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java index d2b2249e08..35456ea458 100644 --- a/org.springframework.jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java +++ b/org.springframework.jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.QueueSession; import javax.jms.Session; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; import javax.jms.Topic; import javax.jms.TopicSession; @@ -323,16 +325,18 @@ public class CachingConnectionFactory extends SingleConnectionFactory { // let raw JMS invocation throw an exception if Destination (i.e. args[0]) is null if ((methodName.equals("createConsumer") || methodName.equals("createReceiver") || methodName.equals("createSubscriber"))) { - if (args[0] != null) { - return getCachedConsumer((Destination) args[0], + Destination dest = (Destination) args[0]; + if (dest != null && !(dest instanceof TemporaryQueue || dest instanceof TemporaryTopic)) { + return getCachedConsumer(dest, (args.length > 1 ? (String) args[1] : null), (args.length > 2 && (Boolean) args[2]), null); } } else if (methodName.equals("createDurableSubscriber")) { - if (args[0] != null) { - return getCachedConsumer((Destination) args[0], + Destination dest = (Destination) args[0]; + if (dest != null) { + return getCachedConsumer(dest, (args.length > 2 ? (String) args[2] : null), (args.length > 3 && (Boolean) args[3]), (String) args[1]);