Outbound User ID
Spring AMQP 版本 1.6 引入了一种允许为出站消息指定默认用户 ID 的机制。始终可以设置 AmqpHeaders.USER_ID
头,该头现在优先于默认值。这对消息接收者可能有用。对于入站消息,如果消息发布者设置了此属性,该属性将在 AmqpHeaders.RECEIVED_USER_ID
头中提供。请注意,RabbitMQ 会验证用户 ID 是否是连接的实际用户 ID,或者连接允许模拟:https://www.rabbitmq.com/validated-user-id.html。
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 now takes 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 validates that the user ID is the actual user ID for the connection or that the connection allows impersonation.
若要为出站消息配置默认用户 ID,请在 RabbitTemplate
上配置它,并配置出站适配器或网关以使用该模板。类似地,若要在回复上设置用户 ID 属性,请将适当配置的模板注入到入站网关中。有关更多信息,请参见 Spring AMQP 文档:https://docs.spring.io/spring-amqp/reference/html/_reference.html#template-user-id。
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 Spring AMQP documentation for more information.