Integration Endpoints

本节介绍 Spring Integration 提供的各种通道适配器和消息网关,以支持与外部系统进行基于消息的通信。 从 AMQP 到 Zookeeper,每个系统都有其自己的集成要求,本节涵盖了这些要求。

Endpoint Quick Reference Table

如前几节所述,Spring Integration 提供了许多端点,用于与外部系统、文件系统等进行接口。

对于透明的依赖管理,Spring Integration 提供了一个物料清单 POM,用于导入 Maven 配置:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-bom</artifactId>
            <version>{project-version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

回顾一下:

  • 入站通道适配器用于单向集成,将数据带入消息传递应用程序。

  • 出站通道适配器用于单向集成,将数据发送出消息传递应用程序。

  • 入站网关用于双向集成流程,其中其他系统调用消息传递应用程序并收到答复。

  • 出站网关用于双向集成流程,其中消息传递应用程序调用某些外部服务或实体并期待一个结果。

下表总结了各种端点,并提供了指向相应章节的快速链接。

Table 1. Endpoint Quick Reference
Module Inbound Adapter Outbound Adapter Inbound Gateway Outbound Gateway

AMQP

Inbound Channel Adapter

Outbound Channel Adapter

Inbound Gateway

Outbound Gateway

Apache Camel

N

Outbound Channel Adapter

N

Outbound Gateway

Apache Cassandra

N

Outbound Channel Adapter

N

Outbound Gateway

Debezium

Debezium Inbound Channel Adapter

N

N

N

Events

Receiving Spring Application Events

Sending Spring Application Events

N

N

Feed

Feed Inbound Channel Adapter

N

N

N

File

Reading Files'tail’ing Files

Writing files

N

Writing files

FTP(S)

FTP Inbound Channel Adapter

FTP Outbound Channel Adapter

N

FTP Outbound Gateway

GraphQL

N

N

N

GraphQL Outbound Gateway

Hazelcast

Hazelcast Inbound Channel Adapter

Hazelcast Outbound Channel Adapter

N

N

HTTP

HTTP Namespace Support

HTTP Namespace Support

Http Inbound Components

HTTP Outbound Components

JDBC

Inbound Channel AdapterStored Procedure Inbound Channel Adapter

Outbound Channel AdapterStored Procedure Outbound Channel Adapter

N

Outbound GatewayStored Procedure Outbound Gateway

JMS

Inbound Channel AdapterMessage-driven Channel Adapter

Outbound Channel Adapter

Inbound Gateway

Outbound Gateway

JMX

Notification-listening Channel AdapterAttribute-polling Channel AdapterTree-polling Channel Adapter

Notification-publishing Channel AdapterOperation-invoking Channel Adapter

N

Operation-invoking Outbound Gateway

JPA

Inbound Channel Adapter

Outbound Channel Adapter

N

Updating Outbound GatewayRetrieving Outbound Gateway

Apache Kafka

Message Driven Channel AdapterInbound Channel Adapter

Outbound Channel Adapter

Inbound Gateway

Outbound Gateway

Mail

Mail-receiving Channel Adapter

Mail-sending Channel Adapter

N

N

MongoDB

MongoDB Inbound Channel Adapter

MongoDB Outbound Channel Adapter

N

N

MQTT

Inbound (Message-driven) Channel Adapter

Outbound Channel Adapter

N

N

R2DBC

R2DBC Inbound Channel Adapter

R2DBC Outbound Channel Adapter

N

N

Redis

Redis Inbound Channel AdapterRedis Queue Inbound Channel AdapterRedis Store Inbound Channel AdapterRedis Stream Inbound Channel Adapter

Redis Outbound Channel Adapter, Redis Queue Outbound Channel Adapter, RedisStore Outbound Channel Adapter, Redis Stream Outbound Channel Adapter

Redis Queue Inbound Gateway

Redis Outbound Command GatewayRedis Queue Outbound Gateway

Resource

Resource Inbound Channel Adapter

N

N

N

RSocket

N

N

RSocket Inbound Gateway

RSocket Outbound Gateway

SFTP

SFTP Inbound Channel Adapter

SFTP Outbound Channel Adapter

N

SFTP Outbound Gateway

SMB

SMB Inbound Channel Adapter, SMB Streaming Inbound Channel Adapter

SMB Outbound Channel Adapter

N

SMB Outbound Gateway

STOMP

STOMP Inbound Channel Adapter

STOMP Outbound Channel Adapter

N

N

Stream

Reading from Streams

Writing to Streams

N

N

Syslog

Syslog Inbound Channel Adapter

N

N

N

TCP

TCP Adapters

TCP Adapters

TCP Gateways

TCP Gateways

UDP

UDP Adapters

UDP Adapters

N

N

WebFlux

WebFlux Inbound Channel Adapter

WebFlux Outbound Channel Adapter

Inbound WebFlux Gateway

Outbound WebFlux Gateway

Web Services

N

N

Inbound Web Service Gateways

Outbound Web Service Gateways

Web Sockets

WebSocket Inbound Channel Adapter

WebSocket Outbound Channel Adapter

N

N

XMPP

XMPP MessagesXMPP Presence

XMPP MessagesXMPP Presence

N

N

ZeroMQ

ZeroMQ Inbound Channel Adapter

ZeroMQ outbound Channel Adapter

N

N

此外,正如 Core Messaging 中讨论的那样,Spring Integration 提供了用于连接普通旧 Java 对象 (POJO) 的端点。正如 Channel Adapter 中所讨论的那样,<int:inbound-channel-adapter> 元素允许您轮询 Java 方法以获取数据。<int:outbound-channel-adapter> 元素允许您将数据发送到 void 方法。正如 Messaging Gateways 所讨论的那样,<int:gateway> 元素允许任何 Java 程序调用消息流。这些每个都可以使用而不需要对 Spring Integration 具有任何源级别依赖项。在这种情况下,出站网关的等效项是使用服务激活器(请参见 Service Activator)调用返回某种 Object 的方法。

从版本 5.2.2 开始,所有入站网关都可以使用 errorOnTimeout 布尔标记进行配置,以便在下游流在应答超时期间未返回应答时抛出 MessageTimeoutException。该计时器在该线程返回对网关的控制权之前不会启动,因此通常只在异步下游流时或在下游流因某些处理程序(例如 filter)返回 null 而停止时才起作用。该异常可以在 errorChannel 流中得到处理,例如,为请求客户端生成补偿应答。