Source:
private javax.jms.Message retryableReceiveReply(Session session, Destination replyTo, String messageSelector) throws JMSException { Connection consumerConnection = null; Session consumerSession = session; MessageConsumer messageConsumer = null; long now = System.currentTimeMillis(); JMSException exception = null; boolean isTemporaryReplyTo = replyTo instanceof TemporaryQueue || replyTo instanceof TemporaryTopic; try { do { try { messageConsumer = consumerSession.createConsumer(replyTo, messageSelector); javax.jms.Message reply = receiveReplyMessage(messageConsumer); if (reply == null) { if (this.receiveTimeout < 0 || now + this.receiveTimeout > System.currentTimeMillis()) { throw new JMSException("Consumer closed before timeout"); } } return reply; } catch (JMSException e) { exception = e; if (logger.isDebugEnabled()) { logger.debug("Connection lost waiting for reply, retrying: " + e.getMessage()); } do { try { consumerConnection = createConnection(); consumerSession = createSession(consumerConnection); break; } catch (JMSException ee) { exception = ee; if (logger.isDebugEnabled()) { logger.debug("Could not reconnect, retrying: " + ee.getMessage()); } try { Thread.sleep(1000); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); return null; } } } while (!isTemporaryReplyTo && (this.receiveTimeout < 0 || now + this.receiveTimeout > System.currentTimeMillis())); } } while (!isTemporaryReplyTo && (this.receiveTimeout < 0 || now + this.receiveTimeout > System.currentTimeMillis())); if (isTemporaryReplyTo) { return null; } else { throw exception; } } finally { if (consumerSession != session) { JmsUtils.closeSession(consumerSession); JmsUtils.closeConnection(consumerConnection); } else { JmsUtils.closeMessageConsumer(messageConsumer); } } }

Target:
private javax.jms.Message retryableReceiveReply(Session session, Destination replyTo, String messageSelector) throws JMSException { Connection consumerConnection = null; Session consumerSession = session; MessageConsumer messageConsumer = null; JMSException exception = null; boolean isTemporaryReplyTo = replyTo instanceof TemporaryQueue || replyTo instanceof TemporaryTopic; long replyTimeout = isTemporaryReplyTo ? Long.MIN_VALUE : this.receiveTimeout < 0 ? Long.MAX_VALUE : System.currentTimeMillis() + this.receiveTimeout; try { do { try { messageConsumer = consumerSession.createConsumer(replyTo, messageSelector); javax.jms.Message reply = receiveReplyMessage(messageConsumer); if (reply == null) { if (replyTimeout > System.currentTimeMillis()) { throw new JMSException("Consumer closed before timeout"); } } return reply; } catch (JMSException e) { exception = e; if (logger.isDebugEnabled()) { logger.debug("Connection lost waiting for reply, retrying: " + e.getMessage()); } do { try { consumerConnection = createConnection(); consumerSession = createSession(consumerConnection); break; } catch (JMSException ee) { exception = ee; if (logger.isDebugEnabled()) { logger.debug("Could not reconnect, retrying: " + ee.getMessage()); } try { Thread.sleep(1000); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); return null; } } } while (replyTimeout > System.currentTimeMillis()); } } while (replyTimeout > System.currentTimeMillis()); if (isTemporaryReplyTo) { return null; } else { throw exception; } } finally { if (consumerSession != session) { JmsUtils.closeSession(consumerSession); JmsUtils.closeConnection(consumerConnection); } JmsUtils.closeMessageConsumer(messageConsumer); } }