Spring Integration——参考
本部分参考文档简要介绍 Spring Integration 项目中的 AMQP 支持。
简介
Spring Integration 项目包含基于 Spring AMQP 项目构建的 AMQP Channel Adapter 和 Gateway。这些 adapter 在 Spring Integration 项目中开发和发布。在 Spring Integration 中,“Channel Adapter”是单向的(one-way),而“Gateway”是双向的(请求-回复)。我们提供入站 channel adapter、出站 channel adapter、入站 gateway 和出站 gateway。
由于 AMQP adapter 是 Spring Integration 发布版的一部分,其文档也作为 Spring Integration 发行版的一部分提供。我们在此提供主要特性的简要概览。更多细节参见Spring Integration 参考指南。
入站 Channel Adapter
要从队列接收 AMQP 消息,可以配置 <inbound-channel-adapter>。以下示例展示如何配置入站 channel adapter:
<amqp:inbound-channel-adapter channel="fromAMQP"
queue-names="some.queue"
connection-factory="rabbitConnectionFactory"/>
出站 Channel Adapter
要向 exchange 发送 AMQP 消息,可以配置 <outbound-channel-adapter>。除 exchange 名称外,还可以可选地提供 'routing-key'。以下示例展示如何定义出站 channel adapter:
<amqp:outbound-channel-adapter channel="toAMQP"
exchange-name="some.exchange"
routing-key="foo"
amqp-template="rabbitTemplate"/>
入站 Gateway
要从队列接收 AMQP 消息并回复其 reply-to 地址,可以配置 <inbound-gateway>。以下示例展示如何定义入站 gateway:
<amqp:inbound-gateway request-channel="fromAMQP"
reply-channel="toAMQP"
queue-names="some.queue"
connection-factory="rabbitConnectionFactory"/>
出站 Gateway
要向 exchange 发送 AMQP 消息并从远程客户端接收响应,可以配置 <outbound-gateway>。除 exchange 名称外,还可以可选地提供 'routing-key'。以下示例展示如何定义出站 gateway:
<amqp:outbound-gateway request-channel="toAMQP"
reply-channel="fromAMQP"
exchange-name="some.exchange"
routing-key="foo"
amqp-template="rabbitTemplate"/>