mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Restore early MessageConsumer creation for temporary queue
Closes gh-36321
This commit is contained in:
@@ -957,20 +957,22 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
try {
|
||||
Message requestMessage = messageCreator.createMessage(session);
|
||||
producer = session.createProducer(destination);
|
||||
if (!useCorrelationId) {
|
||||
consumer = session.createConsumer(responseQueue);
|
||||
}
|
||||
requestMessage.setJMSReplyTo(responseQueue);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Sending created message: " + requestMessage);
|
||||
}
|
||||
doSend(producer, requestMessage);
|
||||
String messageSelector = null;
|
||||
if (useCorrelationId) {
|
||||
if (consumer == null) { // useCorrelationId=true
|
||||
String correlationId = requestMessage.getJMSCorrelationID();
|
||||
if (correlationId == null) {
|
||||
correlationId = requestMessage.getJMSMessageID();
|
||||
}
|
||||
messageSelector = "JMSCorrelationID='" + correlationId + "'";
|
||||
String messageSelector = "JMSCorrelationID='" + correlationId + "'";
|
||||
consumer = session.createConsumer(responseQueue, messageSelector);
|
||||
}
|
||||
consumer = session.createConsumer(responseQueue, messageSelector);
|
||||
return receiveFromConsumer(consumer, getReceiveTimeout());
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -648,7 +648,7 @@ class JmsTemplateTests {
|
||||
given(localSession.createTemporaryQueue()).willReturn(replyDestination);
|
||||
|
||||
MessageConsumer messageConsumer = mock();
|
||||
given(localSession.createConsumer(replyDestination, null)).willReturn(messageConsumer);
|
||||
given(localSession.createConsumer(replyDestination)).willReturn(messageConsumer);
|
||||
|
||||
TextMessage request = mock();
|
||||
MessageCreator messageCreator = mock();
|
||||
|
||||
Reference in New Issue
Block a user