diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java index ace6a68442..6e6ede6dad 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java @@ -272,6 +272,12 @@ public class AmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler @Override public void confirm(CorrelationData correlationData, boolean ack) { Object userCorrelationData = correlationData; + if (correlationData == null) { + if (logger.isDebugEnabled()) { + logger.debug("No correlation data provided for ack: " + ack); + } + return; + } if (correlationData instanceof CorrelationDataWrapper) { userCorrelationData = ((CorrelationDataWrapper) correlationData).getUserData(); } diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests-context.xml b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests-context.xml index 96c79e8da1..54e6dafe7f 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests-context.xml @@ -40,9 +40,12 @@ + + @@ -52,9 +55,12 @@ + + diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java index 2a417c6817..0328338362 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java @@ -241,7 +241,7 @@ public class AmqpOutboundChannelAdapterParserTests { Message message = MessageBuilder.withPayload("hello").build(); requestChannel.send(message); PollableChannel returnChannel = context.getBean("returnChannel", PollableChannel.class); - RabbitTemplate template = context.getBean("amqpTemplate", RabbitTemplate.class); + RabbitTemplate template = context.getBean("amqpTemplateReturns", RabbitTemplate.class); Map headers = new HashMap(); headers.put(PublisherCallbackChannel.RETURN_CORRELATION, template.getUUID()); BasicProperties properties = mock(BasicProperties.class); diff --git a/src/reference/docbook/amqp.xml b/src/reference/docbook/amqp.xml index 24dbb924f6..8469d0ba8b 100644 --- a/src/reference/docbook/amqp.xml +++ b/src/reference/docbook/amqp.xml @@ -471,10 +471,12 @@ public Object handle(@Payload String payload, @Header(AmqpHeaders.CHANNEL) Chann An expression defining correlation data. When provided, this configures the underlying - amqp template to receive publisher confirms. Requires a RabbitTemplate and a + amqp template to receive publisher confirms. Requires a dedicated + RabbitTemplate and a CachingConnectionFactory with the publisherConfirms property set to true. When a publisher confirm - is received, it is written to either the confirm-ack-channel, or the confirm-nack-channel, + is received, and correlation data is supplied, + it is written to either the confirm-ack-channel, or the confirm-nack-channel, depending on the confirmation type. The payload of the confirm is the correlation data as defined by this expression and the message will have a header 'amqp_publishConfirm' set to true (ack) or false (nack). Examples: "headers['myCorrelationData']", "payload". @@ -497,8 +499,8 @@ public Object handle(@Payload String payload, @Header(AmqpHeaders.CHANNEL) Chann amqp_returnReplyText, amqp_returnExchange, amqp_returnRoutingKey. Optional. - Using a return-channel requires a RabbitTemplate with either - the mandatory or immediate properties set to true, + Using a return-channel requires a RabbitTemplate with + the mandatory property set to true, and a CachingConnectionFactory with the publisherReturns property set to true. When using multiple outbound endpoints with returns, a separate RabbitTemplate is needed @@ -585,8 +587,8 @@ public Object handle(@Payload String payload, @Header(AmqpHeaders.CHANNEL) Chann amqp_returnReplyText, amqp_returnExchange, amqp_returnRoutingKey. Optional. - Using a return-channel requires a RabbitTemplate with either - the mandatory or immediate properties set to true, + Using a return-channel requires a RabbitTemplate with + the mandatory property set to true, and a CachingConnectionFactory with the publisherReturns property set to true. When using multiple outbound endpoints with returns, a separate RabbitTemplate is needed