Spring Integration - Reference

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

Introduction

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

由于 AMQP 适配器是 Spring Integration 版本的一部分,因此文档作为 Spring Integration 发行版的一部分提供。我们在此简要概述主要功能。有关更多详细信息,请参见 Spring Integration Reference Guide

Inbound Channel Adapter

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

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

Outbound Channel Adapter

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

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

Inbound Gateway

若要接收队列中的 AMQP 消息并对其 reply-to 地址进行响应,您可以配置“<inbound-gateway>”。以下示例展示如何定义入站网关:

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

Outbound Gateway

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

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