diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java index 6b10ebcc7f..823dddc6e8 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java @@ -1196,13 +1196,14 @@ public boolean receiveAndReply(String queueName, ReceiveAndReplyCallback< private boolean doReceiveAndReply(final String queueName, final ReceiveAndReplyCallback callback, final ReplyToAddressCallback replyToAddressCallback) throws AmqpException { - return execute(channel -> { - Message receiveMessage = receiveForReply(queueName, channel); - if (receiveMessage != null) { - return sendReply(callback, replyToAddressCallback, channel, receiveMessage); - } - return false; - }, obtainTargetConnectionFactory(this.receiveConnectionFactorySelectorExpression, queueName)); + Boolean result = execute(channel -> { + Message receiveMessage = receiveForReply(queueName, channel); + if (receiveMessage != null) { + return sendReply(callback, replyToAddressCallback, channel, receiveMessage); + } + return false; + }, obtainTargetConnectionFactory(this.receiveConnectionFactorySelectorExpression, queueName)); + return result == null ? false : result; } @Nullable @@ -1307,7 +1308,7 @@ else if (logger.isDebugEnabled()) { } @SuppressWarnings(UNCHECKED) - private Boolean sendReply(final ReceiveAndReplyCallback callback, + private boolean sendReply(final ReceiveAndReplyCallback callback, final ReplyToAddressCallback replyToAddressCallback, Channel channel, Message receiveMessage) throws Exception { // NOSONAR TODO change to IOException in 2.2. @@ -2027,8 +2028,9 @@ private void cleanUpAfterAction(Channel channel, boolean invokeScope, RabbitReso } } + @Nullable private T invokeAction(ChannelCallback action, ConnectionFactory connectionFactory, Channel channel) - throws Exception { + throws Exception { // NOSONAR see the callback if (this.confirmsOrReturnsCapable == null) { determineConfirmsReturnsCapability(connectionFactory);