# 集成端点

# 端点快速参考表

正如前面几节中所讨论的, Spring 集成提供了许多端点,这些端点用于与外部系统、文件系统和其他系统进行接口。

对于透明的依赖管理 Spring,集成提供了要导入到 Maven 配置中的材料清单 POM:

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

总结一下:

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

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

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

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

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

Module Inbound Adapter 出站适配器 Inbound Gateway Outbound Gateway
AMQP Inbound Channel Adapter 出站通道适配器 Inbound Gateway Outbound Gateway
Events Receiving Spring Application Events Sending Spring Application Events N N
Feed Feed Inbound Channel Adapter N N N
File Reading Files and 'tail’ing Files 写入文件 N Writing files
FTP(S) FTP Inbound Channel Adapter FTP 出站通道适配器 N FTP Outbound Gateway
Gemfire Inbound Channel Adapter and Continuous Query Inbound Channel Adapter 出站通道适配器 N N
HTTP HTTP Namespace Support HTTP 命名空间支持 Http Inbound Components HTTP Outbound Components
JDBC Inbound Channel Adapter and Stored Procedure Inbound Channel Adapter 出站通道适配器存储过程出站通道适配器 N Outbound Gateway and Stored Procedure Outbound Gateway
JMS Inbound Channel Adapter and Message-driven Channel Adapter 出站通道适配器 Inbound Gateway Outbound Gateway
JMX Notification-listening Channel Adapter and Attribute-polling Channel Adapter and Tree-polling Channel Adapter 通知发布通道适配器操作调用通道适配器 N Operation-invoking Outbound Gateway
JPA Inbound Channel Adapter 出站通道适配器 N Updating Outbound Gateway and Retrieving Outbound Gateway
Apache Kafka Message Driven Channel Adapter and Inbound Channel Adapter 出站通道适配器 Inbound Gateway Outbound Gateway
Mail Mail-receiving Channel Adapter 邮件发送通道适配器 N N
MongoDB MongoDB Inbound Channel Adapter MongoDB 出站通道适配器 N N
MQTT Inbound (Message-driven) Channel Adapter 出站通道适配器 N N
R2DBC R2DBC Inbound Channel Adapter R2DBC 出站通道适配器 N N
Redis Redis Inbound Channel Adapter, Redis Queue Inbound Channel Adapter, Redis Store Inbound Channel Adapter, Redis Stream Inbound Channel Adapter Redis 出站通道适配器, Redis 队列出站通道适配器, 恢复存储出站通道适配器, Redis 流出站通道适配器 Redis Queue Inbound Gateway Redis Outbound Command Gateway and Redis Queue Outbound Gateway
Resource Resource Inbound Channel Adapter N N N
RMI N N Inbound RMI Outbound RMI
RSocket N N RSocket Inbound Gateway RSocket Outbound Gateway
SFTP SFTP Inbound Channel Adapter SFTP 出站通道适配器 N SFTP Outbound Gateway
STOMP STOMP Inbound Channel Adapter Stomp 出站通道适配器 N N
Stream Reading from Streams 写到流 N N
Syslog Syslog Inbound Channel Adapter N N N
TCP TCP Adapters TCP 适配器 TCP Gateways TCP Gateways
UDP UDP Adapters UDP 适配器 N N
WebFlux WebFlux Inbound Channel Adapter WebFlux 出站通道适配器 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 Messages and XMPP Presence XMPP 消息XMPP 存在 N N
ZeroMQ ZeroMQ Inbound Channel Adapter ZeroMQ 出站通道适配器 N N

此外,如核心消息传递中所讨论的, Spring 集成提供了与普通旧 Java 对象接口的端点。正如通道适配器中所讨论的,<int:inbound-channel-adapter>元素允许你轮询 Java 方法中的数据。<int:outbound-channel-adapter>元素允许你将数据发送到void方法。正如消息传递网关中所讨论的,<int:gateway>元素允许任何 Java 程序调用消息流。所有这些都可以工作,而不需要对 Spring 集成有任何源码级依赖。在此上下文中,相当于出站网关的方法是使用服务激活器(参见服务激活器)来调用返回某种类型的Object的方法。

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