amqp 模板对于 amqp 出站通道适配器是如何可选的

How is the amqp-template optional for an amqp outbound channel adapter

当我查看有关 spring 集成的出站通道适配器的文档时,我看到 amqp-template 是一个可选字段。我还注意到交换名称和路由密钥同时出现在 Rabbit 模板和出站通道适配器上。

如果我不提供 amqp 模板,适配器将使用什么作为连接工厂。

如果我在 rabbit 模板中指定一组属性,在出站通道适配器中指定另一组属性,然后为出站通道适配器提供 rabbit 模板,将使用哪些属性? (并不是说我会那样做,我只是好奇哪个组件的属性比另一个组件使用)

If I did not provide an amqp-template what would the adapter use for the connection factory.

它需要一个来自上下文的 bean 名称 amqpTemplate (AmqpOutboundChannelAdapterParser):

String amqpTemplateRef = element.getAttribute("amqp-template");
if (!StringUtils.hasText(amqpTemplateRef)) {
    amqpTemplateRef = "amqpTemplate";

exchangeroutingKey 等属性用于每个 message(AmqpOutboundEndpoint):

this.amqpTemplate.convertAndSend(exchangeName, routingKey, requestMessage.getPayload(),

ConfirmCallbackReturnCallback 是为 AmqpOutboundEndpoint 中的 AmqpTemplate 配置的。但是在这种情况下,您不能使用共享 bean,必须提供单独的 bean。

必须在该 bean 定义中提供所有其他 RabbitTemplate 特定选项。 <int-amqp:outbound-channel-adapter> 没有。