Author: pmouawad Date: Wed Nov 29 17:30:00 2017 New Revision: 1816642 URL: http://svn.apache.org/viewvc?rev=1816642&view=rev Log: Bug 61829 - JMS Point-to-Point : If Receive Queue is empty and a timeout is set, it is not taken into account Fixes closing order and don't close session as it's closed by caller Bugzilla Id: 61829
Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TimeoutEnabledQueueRequestor.java Modified: jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TimeoutEnabledQueueRequestor.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TimeoutEnabledQueueRequestor.java?rev=1816642&r1=1816641&r2=1816642&view=diff ============================================================================== --- jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TimeoutEnabledQueueRequestor.java (original) +++ jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/TimeoutEnabledQueueRequestor.java Wed Nov 29 17:30:00 2017 @@ -45,7 +45,6 @@ import org.slf4j.LoggerFactory; */ public class TimeoutEnabledQueueRequestor { private static final Logger logger = LoggerFactory.getLogger(TimeoutEnabledQueueRequestor.class); - private Session session; // The queue session to which the queue belongs. private TemporaryQueue tempQueue; private MessageProducer sender; private MessageConsumer receiver; @@ -58,8 +57,8 @@ public class TimeoutEnabledQueueRequesto * with a delivery mode of either <code>AUTO_ACKNOWLEDGE</code> or * <code>DUPS_OK_ACKNOWLEDGE</code>. * - * @paramsession the <code>QueueSession</code> the queue belongs to - * @paramqueue the queue to performthe request/reply call on + * @param session the <code>QueueSession</code> the queue belongs to, session will not be closed by {@link TimeoutEnabledQueueRequestor} + * @param queue the queue to performthe request/reply call on * * @exception JMSException * if the JMS provider fails to create the @@ -69,7 +68,6 @@ public class TimeoutEnabledQueueRequesto * if an invalid queue is specified. */ public TimeoutEnabledQueueRequestor(Session session, Queue queue) throws JMSException { - this.session = session; tempQueue = session.createTemporaryQueue(); sender = session.createProducer(queue); receiver = session.createConsumer(tempQueue); @@ -80,7 +78,7 @@ public class TimeoutEnabledQueueRequesto * the <code>JMSReplyTo</code> destination, and only one reply per request * is expected. The method blocks indefinitely until a message arrives! * - * @parammessage the message to send + * @param message the message to send * * @return the reply message * @@ -139,15 +137,19 @@ public class TimeoutEnabledQueueRequesto public void close() throws JMSException { String queueName = tempQueue.getQueueName(); try { - tempQueue.delete(); - } catch (Exception e) { - logger.error("Error deleting tempQueue {}", queueName); + sender.close(); + } catch (Exception e1) { + logger.error("Error closing sender"); } - // publisher and consumer created by constructor are implicitly closed. try { - session.close(); + receiver.close(); + } catch (Exception e1) { + logger.error("Error closing receiver"); + } + try { + tempQueue.delete(); } catch (Exception e) { - logger.error("Error closing session", e); + logger.error("Error deleting tempQueue {}", queueName); } } }