Spring Integration - 参考

参考文档的这一部分快速介绍了 Spring Integration 项目中的 AMQP 支持。

引言

Spring Integration 项目包含基于 Spring AMQP 项目构建的 AMQP 通道适配器和网关。这些适配器在 Spring Integration 项目中开发和发布。在 Spring Integration 中,“通道适配器”是单向的,而“网关”是双向的(请求-回复)。我们提供了一个入站通道适配器、一个出站通道适配器、一个入站网关和一个出站网关。

由于 AMQP 适配器是 Spring Integration 发布的一部分,文档可在 Spring Integration 分发中获取。我们在此处快速概述了主要功能。有关更多详细信息,请参阅Spring Integration 参考指南

入站通道适配器

要从队列接收 AMQP 消息,您可以配置一个<inbound-channel-adapter>。以下示例展示了如何配置入站通道适配器

<amqp:inbound-channel-adapter channel="fromAMQP"
                              queue-names="some.queue"
                              connection-factory="rabbitConnectionFactory"/>

出站通道适配器

要向交换器发送 AMQP 消息,您可以配置一个<outbound-channel-adapter>。除了交换器名称外,您还可以选择提供“路由键”。以下示例展示了如何定义出站通道适配器

<amqp:outbound-channel-adapter channel="toAMQP"
                               exchange-name="some.exchange"
                               routing-key="foo"
                               amqp-template="rabbitTemplate"/>

入站网关

要从队列接收 AMQP 消息并回复其“reply-to”地址,您可以配置一个<inbound-gateway>。以下示例展示了如何定义入站网关

<amqp:inbound-gateway request-channel="fromAMQP"
                      reply-channel="toAMQP"
                      queue-names="some.queue"
                      connection-factory="rabbitConnectionFactory"/>

出站网关

要向交换器发送 AMQP 消息并从远程客户端接收响应,您可以配置一个<outbound-gateway>。除了交换器名称外,您还可以选择提供“路由键”。以下示例展示了如何定义出站网关

<amqp:outbound-gateway request-channel="toAMQP"
                       reply-channel="fromAMQP"
                       exchange-name="some.exchange"
                       routing-key="foo"
                       amqp-template="rabbitTemplate"/>
© . This site is unofficial and not affiliated with VMware.