参考文档的这一部分简要介绍了 Spring Integration 项目中的 AMQP 支持。
介绍
Spring Integration 项目包括基于 Spring AMQP 项目构建的 AMQP 通道适配器和网关。 这些适配器是在 Spring Integration 项目中开发和发布的。 在Spring Integration中,“通道适配器”是单向的(单向),而“网关”是双向的(请求-回复)。 我们提供入站通道适配器、出站通道适配器、入站网关和出站网关。
由于 AMQP 适配器是 Spring Integration 版本的一部分,因此该文档作为 Spring Integration 发行版的一部分提供。 我们在这里提供了主要功能的快速概述。 有关更多详细信息,请参阅 Spring 集成参考指南。
入站通道适配器
若要从队列接收 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 消息并响应其回复地址,可以配置 .
以下示例演示如何定义入站网关:<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"/>