From 16f9c9ae495c56028f61d7116661897b748f3fa6 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 26 May 2016 10:01:15 -0400 Subject: [PATCH] INT-4041: AMQP: Map receivedUserId JIRA: https://jira.spring.io/browse/INT-4041 Polish the `AMQP-1.6.0` link to be more generic and refer --- .../amqp/support/DefaultAmqpHeaderMapper.java | 4 ++-- .../amqp/StubRabbitConnectionFactory.java | 5 +++++ .../amqp/support/DefaultAmqpHeaderMapperTests.java | 4 ++-- src/reference/asciidoc/amqp.adoc | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java index 2d58f40a45..5cd0b78037 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/DefaultAmqpHeaderMapper.java @@ -215,9 +215,9 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper headerMap = headerMapper.toHeadersFromReply(amqpProperties); @@ -195,7 +195,7 @@ public class DefaultAmqpHeaderMapperTests { assertEquals("test.replyTo", headerMap.get(AmqpHeaders.REPLY_TO)); assertEquals(testTimestamp, headerMap.get(AmqpHeaders.TIMESTAMP)); assertEquals("test.type", headerMap.get(AmqpHeaders.TYPE)); - assertEquals("test.userId", headerMap.get(AmqpHeaders.USER_ID)); + assertEquals("test.userId", headerMap.get(AmqpHeaders.RECEIVED_USER_ID)); assertEquals("test.correlation", headerMap.get(AmqpHeaders.SPRING_REPLY_CORRELATION)); assertEquals("test.replyTo2", headerMap.get(AmqpHeaders.SPRING_REPLY_TO_STACK)); } diff --git a/src/reference/asciidoc/amqp.adoc b/src/reference/asciidoc/amqp.adoc index b25cfe261b..c0ba93e924 100644 --- a/src/reference/asciidoc/amqp.adoc +++ b/src/reference/asciidoc/amqp.adoc @@ -1137,6 +1137,20 @@ JSON converter to be selected. This applies to both the outbound channel adapter and gateway. +[[amqp-user-id]] +=== Outbound User Id + +Spring AMQP _version 1.6_ introduced a mechanism to allow the specification of a default user id for outbound messages. +It has always been possible to set the `AmqpHeaders.USER_ID` header which will now take precedence over the default. +This might be useful to message recipients; for inbound messages, if the message publisher sets the property, it is made available in the `AmqpHeaders.RECEIVED_USER_ID` header. +Note that RabbitMQ https://www.rabbitmq.com/validated-user-id.html[validates that the user id is the actual user id for the connection or one for which impersonation is allowed]. + +To configure a default user id for outbound messages, configure it on a `RabbitTemplate` and configure the outbound adapter or gateway to use that template. +Similarly, to set the user id property on replies, inject an appropriately configured template into the inbound gateway. +See the http://docs.spring.io/spring-amqp/reference/html/_reference.html#template-user-id[Spring AMQP documentation] for more information. + + + [[amqp-channels]] === AMQP Backed Message Channels