如需使用最新稳定版本,请使用 Spring Integration 7.0.4spring-doc.cadn.net.cn

4.1 与 4.2 之间的变更

请参阅 迁移指南 以了解可能影响您应用程序的重要变更。 您可以在 Wiki 上找到从 2.1 版本起所有版本的迁移指南。spring-doc.cadn.net.cn

新组件

版本4.2添加了许多新组件。spring-doc.cadn.net.cn

主要管理/JMX 重构

我们新增了一个 MetricsFactory 策略接口。 此变更连同 JMX 和管理基础设施中的其他变更,提供了对管理配置和运行时性能的更多控制能力。spring-doc.cadn.net.cn

然而,这对(某些)用户环境有一些重要的影响。spring-doc.cadn.net.cn

有关完整详细信息,请参阅指标与管理JMX 改进spring-doc.cadn.net.cn

MongoDB 元数据存储

MongoDbMetadataStore 现已可用。 有关更多信息,请参阅 MongoDB 元数据存储spring-doc.cadn.net.cn

SecuredChannel 注解

我们介绍了 @SecuredChannel 注解,以取代已弃用的 ChannelSecurityInterceptorFactoryBean。 如需更多信息,请参阅 Spring Integration 中的安全性spring-doc.cadn.net.cn

SecurityContext传播

我们介绍了SecurityContextPropagationChannelInterceptor用于将SecurityContext传播从一个消息流的线程传递到另一个线程。 更多信息,请参见Spring Integration 中的安全性spring-doc.cadn.net.cn

文件分割器

在 4.1.2 版本中,我们添加了 FileSplitter,它可以将文本文件按行分割。 现在它在 int-file: 命名空间中得到了全面支持。 有关更多信息,请参阅 文件分割器spring-doc.cadn.net.cn

Zookeeper 支持

我们为该框架添加了 Zookeeper 支持,以协助在集群或多主机环境中运行。 此变更影响以下功能:spring-doc.cadn.net.cn

有关更多信息,请参见 Zookeeper 支持spring-doc.cadn.net.cn

线程屏障

一个新的线程 <int:barrier/> 组件已可用,它允许线程挂起直到发生某个异步事件。 有关更多信息,请参阅 线程屏障 (Thread Barrier)spring-doc.cadn.net.cn

STOMP 支持

我们已将 STOMP 支持添加到框架中,作为一对入站和出站通道适配器。 有关更多信息,请参阅 STOMP 支持spring-doc.cadn.net.cn

编解码器

引入了一个新的Codec抽象,用于将对象编码和解码为byte[]。 我们添加了一个使用 Kryo 的实现。 我们还添加了基于编解码器的转换器和消息转换器。 有关更多信息,请参阅Codecspring-doc.cadn.net.cn

消息 PreparedStatement Setter

对于 MessagePreparedStatementSetter<int-jdbc:outbound-gateway><int-jdbc:outbound-channel-adapter>)的 JdbcMessageHandler,新增了一个 requestMessage 上下文的替代方案,用于通过 SqlParameterSourceFactoryPreparedStatement 填充参数,该方案使用新的 MessagePreparedStatementSetter 函数式接口回调。 有关更多信息,请参阅 出站通道适配器spring-doc.cadn.net.cn

常规变更

本节描述了从版本 4.1 到版本 4.2 的通用变更。spring-doc.cadn.net.cn

消息拦截

作为现有 selector 属性的替代方案,<wire-tap/> 元素现在支持 selector-expression 属性。spring-doc.cadn.net.cn

文件更改

有关这些更改的更多信息,请参阅 文件支持spring-doc.cadn.net.cn

追加新行

The <int-file:outbound-channel-adapter> and <int-file:outbound-gateway> 现在支持一个 append-new-line 属性。 如果设置为 true,则在写入消息后会在文件末尾追加新行。 该属性的默认值为 falsespring-doc.cadn.net.cn

忽略隐藏文件

我们为ignore-hidden属性添加了<int-file:inbound-channel-adapter>,以便您可以设置是否从源目录中获取隐藏文件。 它默认为truespring-doc.cadn.net.cn

正在写入InputStream负载

The FileWritingMessageHandler now also accepts InputStream as a valid message payload type.spring-doc.cadn.net.cn

HeadDirectoryScanner

您现在可以将 HeadDirectoryScanner 与其他 FileListFilter 实现一起使用。spring-doc.cadn.net.cn

最后修改过滤器

我们添加了 LastModifiedFileListFilterspring-doc.cadn.net.cn

Watch Service Directory Scanner

我们添加了 WatchServiceDirectoryScannerspring-doc.cadn.net.cn

持久化文件列表过滤器更改

AbstractPersistentFileListFilter 新增了一个属性 (flushOnUpdate),当该属性设置为 true 时,如果元数据存储器实现了 Flushable(例如 PropertiesPersistingMetadataStore),则会调用 flush()spring-doc.cadn.net.cn

类包变更

我们将 ScatterGatherHandler 类从 org.springframework.integration.handler 移动到了 org.springframework.integration.scattergatherspring-doc.cadn.net.cn

TCP 变更

本节介绍 Spring Integration TCP 功能的一般变更。spring-doc.cadn.net.cn

TCP 序列化器

TCP Serializers不再flush()OutputStream。 现在由TcpNxxConnection类完成。 如果您直接在代码中使用序列化器,可能需要flush()OutputStreamspring-doc.cadn.net.cn

服务器套接字异常

TcpConnectionServerExceptionEvent 个实例现在会在 TCP 服务器套接字上发生意外异常时发布(也已添加到 4.1.3 和 4.0.7)。 有关更多信息,请参阅 TCP 连接事件spring-doc.cadn.net.cn

TCP 服务器端口

如果您配置一个 TCP 服务器套接字工厂以监听随机端口,现在可以通过使用 getPort() 获取操作系统实际选择的端口。 getServerSocketAddress() 也可用。spring-doc.cadn.net.cn

有关更多信息,请参阅"TCP 连接工厂"。spring-doc.cadn.net.cn

TCP 网关远程超时

The TcpOutboundGateway now supports remote-timeout-expression as an alternative to the existing remote-timeout attribute. This allows setting the timeout based on each message.spring-doc.cadn.net.cn

此外,remote-timeout 不再默认与 reply-timeout 具有相同的值,而后者具有完全不同的含义。spring-doc.cadn.net.cn

有关更多信息,请参阅 .TCP 出站网关属性spring-doc.cadn.net.cn

TCP SSLSession 可用于标题映射

TcpConnection 实现现在支持 getSslSession(),以便您从会话中提取信息并添加到消息头中。 有关更多信息,请参阅 IP 消息头spring-doc.cadn.net.cn

TCP 事件

每当发生关联异常(例如向不存在的套接字发送消息)时,现在都会发布新的事件。spring-doc.cadn.net.cn

TcpConnectionEventListeningMessageProducer 已弃用。 请改用通用事件适配器。spring-doc.cadn.net.cn

有关更多信息,请参阅TCP 连接事件spring-doc.cadn.net.cn

@InboundChannelAdapter变更

以前,入站通道适配器的 @Poller 默认将 maxMessagesPerPoll 属性设置为 -1(无穷大)。 这与 <inbound-channel-adapter/> 的 XML 配置不一致,后者默认为 1。 现在注解将该属性默认值设置为 1spring-doc.cadn.net.cn

API 变更

o.s.integration.util.FunctionIterator now requires a o.s.integration.util.Function instead of a reactor.function.Function. This was done to remove an unnecessary hard dependency on Reactor. Any uses of this iterator need to change the import.spring-doc.cadn.net.cn

Reactor 仍然受支持,用于诸如 Promise 网关等功能。 对于不需要该功能的用户,已移除了相关依赖项。spring-doc.cadn.net.cn

JMS 变更

本节介绍 Spring Integration TCP 功能的一般变更。spring-doc.cadn.net.cn

回复监听器延迟初始化

您现在可以在 JMS 出站网关中将回复监听器的配置设置为按需初始化,并在空闲期后停止,而不是由网关的生命周期控制。 有关更多信息,请参见 出站网关spring-doc.cadn.net.cn

消息驱动端点中的转换错误

error-channel 现在用于转换错误。 在之前的版本中,它们会导致事务回滚和消息重新投递。spring-doc.cadn.net.cn

有关更多信息,请参阅 消息驱动通道适配器入站网关spring-doc.cadn.net.cn

默认确认模式

当使用隐式定义的 DefaultMessageListenerContainer 时,默认的 acknowledge 现在为 transacted。 我们建议在使用此容器时使用 transacted,以避免消息丢失。 此默认设置现在适用于消息驱动的入站适配器(inbound adapter)和入站网关(inbound gateway)。 对于基于 JMS 的通道,它早已是默认值。spring-doc.cadn.net.cn

有关更多信息,请参阅 消息驱动通道适配器入站网关spring-doc.cadn.net.cn

共享订阅

我们已为消息驱动端点和<int-jms:publish-subscribe-channel>添加了共享订阅(JMS 2.0)的命名空间支持。 此前,若要使用共享连接,必须将监听器容器配置为<bean/>声明。spring-doc.cadn.net.cn

有关更多信息,请查看 JMS 支持spring-doc.cadn.net.cn

条件轮询器

我们现在为动态轮询提供了更多的灵活性。spring-doc.cadn.net.cn

有关更多信息,请参阅消息源的条件轮询器spring-doc.cadn.net.cn

AMQP 变更

本节介绍 Spring Integration AMQP 功能的一般变更。spring-doc.cadn.net.cn

发布者确认

The <int-amqp:outbound-gateway> now supports confirm-correlation-expression, confirm-ack-channel, and confirm-nack-channel attributes (which have a purpose similar to that of <int-amqp:outbound-channel-adapter>).spring-doc.cadn.net.cn

关联数据

对于出站通道适配器和入站网关,如果关联数据为 Message<?>,它将作为确认或否定确认通道上消息的基础,并附加额外的头部信息。 此前,任何关联数据(包括 Message<?>)都会作为确认或否定确认消息的有效负载返回。spring-doc.cadn.net.cn

入站网关属性

The <int-amqp:inbound-gateway> now exposes the amqp-template attribute to allow more control over an external bean for the reply RabbitTemplate. You can also provide your own AmqpTemplate implementation. In addition, you can use default-reply-to if the request message does not have a replyTo property.spring-doc.cadn.net.cn

有关更多信息,请参阅 AMQP 支持spring-doc.cadn.net.cn

XPath 拆分器改进

The XPathMessageSplitter (<int-xml:xpath-splitter>) now allows the configuration of output-properties for the internal javax.xml.transform.Transformer and supports an Iterator mode (defaults to true) for the XPath evaluation org.w3c.dom.NodeList result.spring-doc.cadn.net.cn

有关更多信息,请参阅 拆分 XML 消息spring-doc.cadn.net.cn

HTTP 变更

本节描述了 Spring Integration HTTP 功能的一般变更。spring-doc.cadn.net.cn

CORS(跨域资源共享)

The HTTP inbound endpoints (<int-http:inbound-channel-adapter> and <int-http:inbound-gateway>) now allow the configuration of Cross-origin Resource Sharing (CORS).spring-doc.cadn.net.cn

有关更多信息,请参见 跨域资源共享 (CORS) 支持spring-doc.cadn.net.cn

入站网关超时

您可以配置 HTTP 入站网关,使其在请求超时时返回您指定的状态码。 默认值现在是 500 Internal Server Error,而不是 200 OKspring-doc.cadn.net.cn

有关更多信息,请参阅 响应状态码spring-doc.cadn.net.cn

表单数据

我们已添加关于代理 multipart/form-data 请求的文档。 有关更多信息,请参阅 HTTP 支持spring-doc.cadn.net.cn

网关变更

本节描述了对 Spring Integration Gateway 功能的通用更改。spring-doc.cadn.net.cn

[[gateway-methods-can-return-completablefuture<?>]] ==== Gateway 方法可以返回 CompletableFuture<?>spring-doc.cadn.net.cn

使用 Java 8 时,网关方法现在可以返回 CompletableFuture<?>。 更多信息请参见 CompletableFuturespring-doc.cadn.net.cn

MessagingGateway 注解

请求和响应超时属性现在为 String 而不是 Long,以允许使用属性占位符或 SpEL 进行配置。 请参阅 @MessagingGateway 注解spring-doc.cadn.net.cn

聚合器变更

本节介绍 Spring Integration 聚合器功能的一般变更。spring-doc.cadn.net.cn

聚合器性能

本次发布包含一些针对聚合组件(包括聚合器、重排序器等)的性能改进,通过更高效地在消息释放时将其从组中移除来实现。 已在消息存储中添加了新方法 (removeMessagesFromGroup)。 设置 removeBatchSize 属性(默认值:100)可调整每次操作删除的消息数量。 目前,JDBC、Redis 和 MongoDB 消息存储支持此属性。spring-doc.cadn.net.cn

输出消息组处理器

当为聚合器使用 ref 或内部 Bean 时,现在可以直接绑定 MessageGroupProcessor。 此外,我们添加了一个 SimpleMessageGroupProcessor,用于返回组中的消息集合。 当输出处理器产生 Message<?> 的集合时,聚合器会逐个释放这些消息。 配置 SimpleMessageGroupProcessor 可使聚合器成为消息屏障,消息将被暂存直到全部到达,随后再逐个释放。 有关更多信息,请参阅 聚合器spring-doc.cadn.net.cn

FTP 和 SFTP 变更

本节描述了 Spring Integration FTP 和 SFTP 功能的通用变更。spring-doc.cadn.net.cn

入站通道适配器

您现在可以在入站通道适配器上指定 remote-directory-expression,以在运行时确定目录。 有关更多信息,请参阅 FTP/FTPS 适配器SFTP 适配器spring-doc.cadn.net.cn

网关部分结果

当您使用 FTP 或 SFTP 出站网关操作多个文件(包含 mgetmput)时,在部分请求完成后可能会发生异常。 如果发生此类情况,将抛出一个包含部分结果的 PartialSuccessException。 有关更多信息,请参阅 FTP 出站网关SFTP 出站网关spring-doc.cadn.net.cn

委托会话工厂

我们添加了一个委托会话工厂,使得能够基于某些线程上下文值来选择特定的会话工厂。spring-doc.cadn.net.cn

有关更多信息,请参阅 委托会话工厂委托会话工厂spring-doc.cadn.net.cn

默认 Sftp 会话工厂

此前,DefaultSftpSessionFactory无条件允许连接到未知主机。 现在此行为可配置(默认值:false)。spring-doc.cadn.net.cn

工厂现在需要一个已配置的 knownHosts,除非 allowUnknownKeys 属性为 true(默认值:false),否则必须提供文件。spring-doc.cadn.net.cn

消息会话回调

我们在 <int-(s)ftp:outbound-gateway/> 中介绍了如何使用 requestMessage 上下文执行任何自定义 Session 操作,并引入了 MessageSessionCallback<F, T>spring-doc.cadn.net.cn

WebSocket 变更

我们向 WebSocketHandlerDecoratorFactory 添加了 ServerWebSocketContainer 支持,以便为内部 WebSocketHandler 实现链式自定义。 有关更多信息,请参阅 WebSockets 命名空间支持spring-doc.cadn.net.cn

应用程序事件适配器更改

The ApplicationEvent 适配器现在可以像 payload 作为 event 一样工作,从而直接允许省略自定义的 ApplicationEvent 扩展。 为此,我们在 <int-event:outbound-channel-adapter> 上引入了名为 publish-payload 的布尔属性。 有关更多信息,请参阅 Spring ApplicationEvent 支持spring-doc.cadn.net.cn