Changes between 4.1 and 4.2

查看 Migration Guide,了解可能影响你的应用程序的重要更改。你可以在 wiki 上找到所有版本回溯至 2.1 的迁移指南。

See the Migration Guide for important changes that might affect your applications. You can find migration guides for all versions back to 2.1 on the wiki.

New Components

版本 4.2 添加了许多新组件。

Version 4.2 added a number of new components.

Major Management/JMX Rework

我们添加了新的 MetricsFactory 策略接口。此变更与 JMX 和管理基础设施中的其他变更一起,提供了对管理配置和运行时性能的更多控制。

We added a new MetricsFactory strategy interface. This change, together with other changes in the JMX and management infrastructure, provides much more control over management configuration and runtime performance.

但是,这对于(某些)用户环境有一些重要影响。

However, this has some important implications for (some) user environments.

有关完整详细信息,请参见 Metrics and ManagementJMX Improvements

For complete details, see Metrics and Management and JMX Improvements.

MongoDB Metadata Store

MongoDbMetadataStore 现已发布。有关更多信息,请参见 MongoDB Metadata Store

The MongoDbMetadataStore is now available. For more information, see MongoDB Metadata Store.

SecuredChannel Annotation

我们推出了 @SecuredChannel`注释,以取代已弃用的 `ChannelSecurityInterceptorFactoryBean。更多信息,请参见 Security in Spring Integration

We introduced the @SecuredChannel annotation, replacing the deprecated ChannelSecurityInterceptorFactoryBean. For more information, see Security in Spring Integration.

SecurityContext Propagation

我们推出了 `SecurityContextPropagationChannelInterceptor`以供从一个消息流程的线程传播到另一个线程以供 `SecurityContext`使用。有关更多信息,请参见 Security in Spring Integration

We introduced the SecurityContextPropagationChannelInterceptor for the SecurityContext propagation from one message flow’s thread to another. For more information, see Security in Spring Integration.

FileSplitter

在 4.1.2 中,我们添加了 FileSplitter,它将文本文件分割成行。现在它在 int-file: 名称空间中获得了完全支持。有关更多信息,请参见 File Splitter

In 4.1.2, we added FileSplitter, which splits text files into lines. It now has full support in the int-file: namespace. See File Splitter for more information.

Zookeeper Support

我们在框架中添加了 Zookeeper 支持以协助在集群或多主机环境中运行。该变更影响以下功能:

We added Zookeeper support to the framework to assist when running on a clustered or multi-host environment. The change impacts the following features:

  • ZookeeperMetadataStore

  • ZookeeperLockRegistry

  • Zookeeper Leadership

有关更多信息,请参见 Zookeeper Support

See Zookeeper Support for more information.

Thread Barrier

一个新的线程 <int:barrier/> 组件可用,这允许一个线程在发生某些异步事件之前被挂起。有关更多信息,请参见 Thread Barrier

A new thread <int:barrier/> component is available, letting a thread be suspended until some asynchronous event occurs. See Thread Barrier for more information.

STOMP Support

我们添加了 STOMP 支持到框架中,作为入站和出站通道适配器对。有关更多信息,请参见 STOMP Support

We added STOMP support to the framework as an inbound and outbound channel adapters pair. See STOMP Support for more information.

Codec

一个新的 Codec 抽象已被引入,用来将对象编解码至 byte[]。我们添加了一个使用 Kryo 的实现。我们还添加了基于编解码器的转换器和消息转换器。有关更多信息,请参见 Codec

A new Codec abstraction has been introduced, to encode and decode objects to and from byte[]. We added an implementation that uses Kryo. We also added codec-based transformers and message converters. See Codec for more information.

Message PreparedStatement Setter

一个新的 MessagePreparedStatementSetter 函数式接口回调可用来 JdbcMessageHandler (<int-jdbc:outbound-gateway><int-jdbc:outbound-channel-adapter>),作为使用 SqlParameterSourceFactoryrequestMessage 文本中的参数填充至 PreparedStatement 的替代手段。有关更多信息,请参见 Outbound Channel Adapter

A new MessagePreparedStatementSetter functional interface callback is available for the JdbcMessageHandler (<int-jdbc:outbound-gateway> and <int-jdbc:outbound-channel-adapter>) as an alternative to using SqlParameterSourceFactory to populate parameters on the PreparedStatement with the requestMessage context. See Outbound Channel Adapter for more information.

General Changes

本节描述了从版本 4.1 到版本 4.2 的一般性变更。

This section describes general changes from version 4.1 to version 4.2.

WireTap

作为对现有 selector 属性的替代,<wire-tap/> 元素现在支持 selector-expression 属性。

As an alternative to the existing selector attribute, the <wire-tap/> element now supports the selector-expression attribute.

File Changes

有关这些更改的更多信息,请参见 File Support

See File Support for more information about these changes.

Appending New Lines

<int-file:outbound-channel-adapter><int-file:outbound-gateway> 现在支持 append-new-line 属性。如果设置为 true,在消息写入后,会将新行追加到文件中。默认属性值为 false

The <int-file:outbound-channel-adapter> and <int-file:outbound-gateway> now support an append-new-line attribute. If set to true, a new line is appended to the file after a message is written. The default attribute value is false.

Ignoring Hidden Files

我们为`<int-file:inbound-channel-adapter>`添加了`ignore-hidden`属性,以便您可以设置是否从源目录中拾取隐藏文件。其默认为`true`。

We added the ignore-hidden attribute for the <int-file:inbound-channel-adapter> to let you set whether to pick up hidden files from the source directory. It defaults to true.

Writing InputStream Payloads

`FileWritingMessageHandler`现在也接受`InputStream`作为有效的消息负载类型。

The FileWritingMessageHandler now also accepts InputStream as a valid message payload type.

HeadDirectoryScanner

您现在可以使用`HeadDirectoryScanner`与其他`FileListFilter`实现一起使用。

You can now use the HeadDirectoryScanner with other FileListFilter implementations.

Last Modified Filter

我们添加了`LastModifiedFileListFilter`。

We added the LastModifiedFileListFilter.

Watch Service Directory Scanner

我们添加了`WatchServiceDirectoryScanner`。

We added the WatchServiceDirectoryScanner.

Persistent File List Filter Changes

AbstractPersistentFileListFilter`有一个新属性(`flushOnUpdate),当设置为`true`时,它将在元数据存储中调用`flush()(如果实现了`Flushable(例如,PropertiesPersistingMetadataStore))。

The AbstractPersistentFileListFilter has a new property (flushOnUpdate) which, when set to true, calls flush() on the metadata store if it implements Flushable (for example, PropertiesPersistingMetadataStore).

Class Package Change

我们将`ScatterGatherHandler`类从`org.springframework.integration.handler`移至`org.springframework.integration.scattergather`。

We moved the ScatterGatherHandler class from the org.springframework.integration.handler to the org.springframework.integration.scattergather.

TCP Changes

本节介绍了 Spring Integration TCP 功能的总体更改。

This section describes general changes to the Spring Integration TCP functionality.

TCP Serializers

TCP Serializers`不再`flush() OutputStream。现在由`TcpNxxConnection`类完成此操作。如果您直接在代码中使用序列化器,则可能需要`flush()` OutputStream

The TCP Serializers no longer flush() the OutputStream. This is now done by the TcpNxxConnection classes. If you use the serializers directly within your code, you may have to flush() the OutputStream.

Server Socket Exceptions

无论何时在 TCP 服务器套接字上发生意外异常(也已添加到 4.1.3 和 4.0.7),现在都会发布 TcpConnectionServerExceptionEvent 实例。有关更多信息,请参见 TCP Connection Events

TcpConnectionServerExceptionEvent instances are now published whenever an unexpected exception occurs on a TCP server socket (also added to 4.1.3 and 4.0.7). See TCP Connection Events for more information.

TCP Server Port

如果您将 TCP 服务器套接字工厂配置为监听随机端口,现在可以使用`getPort()`获取 OS 选择的实际端口。`getServerSocketAddress()`也可使用。

If you configure a TCP server socket factory to listen on a random port, you can now obtain the actual port chosen by the OS by using getPort(). getServerSocketAddress() is also available.

有关更多信息,请参见 "TCP Connection Factories"。

See "TCP Connection Factories" for more information.

TCP Gateway Remote Timeout

`TcpOutboundGateway`现在支持`remote-timeout-expression`作为现有`remote-timeout`属性的替代方法。这允许根据每条消息设置超时。

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.

此外,`remote-timeout`不再默认为与`reply-timeout`相同的值,而后者的含义完全不同。

Also, the remote-timeout no longer defaults to the same value as reply-timeout, which has a completely different meaning.

有关更多信息,请参见 .TCP Outbound Gateway Attributes

See .TCP Outbound Gateway Attributes for more information.

TCP SSLSession Available for Header Mapping

TcpConnection 实现现在支持 getSslSession(),让你能够从中提取信息来添加到消息头。有关更多信息,请参见 IP Message Headers

TcpConnection implementations now support getSslSession() to let you extract information from the session to add to message headers. See IP Message Headers for more information.

TCP Events

现在,每当出现关联异常(例如,将消息发送到不存在的套接字)时,都会发布新事件。

New events are now published whenever a correlation exception occurs — such as sending a message to a non-existent socket.

`TcpConnectionEventListeningMessageProducer`已弃用。请改用通用事件适配器。

The TcpConnectionEventListeningMessageProducer is deprecated. Use the generic event adapter instead.

有关更多信息,请参见 TCP Connection Events

See TCP Connection Events for more information.

@InboundChannelAdapter Changes

以前,传入通道适配器上的 @PollermaxMessagesPerPoll 属性的默认值设置为 -1(无限)。这与 <inbound-channel-adapter/> 的 XML 配置不一致,后者的默认值是 1。注释现在将此属性的默认值设置为 1

Previously, the @Poller on an inbound channel adapter defaulted the maxMessagesPerPoll attribute to -1 (infinity). This was inconsistent with the XML configuration of <inbound-channel-adapter/>, which defaults to 1. The annotation now defaults this attribute to 1.

API Changes

o.s.integration.util.FunctionIterator 现在需要 o.s.integration.util.Function 而不需要 reactor.function.Function。这样做是为了移除对 Reactor 不必要的硬依赖。使用此迭代器的任何代码都需要更改导入。

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.

仍然可以为 Promise 网关等功能提供 Reactor 支持。此依赖关系已为不需要此依赖关系的用户移除。

Reactor is still supported for functionality such as the Promise gateway. The dependency was removed for those users who do not need it.

JMS Changes

本节介绍了 Spring Integration TCP 功能的总体更改。

This section describes general changes to the Spring Integration TCP functionality.

Reply Listener Lazy Initialization

你现在可以将 JMS 出站网关中的回复侦听器配置为在闲置一段时间后按需初始化并停止,而不是由网关的生命周期控制。有关更多信息,请参见 Outbound Gateway

You can now configure the reply listener in JMS outbound gateways to be initialized on-demand and stopped after an idle period, instead of being controlled by the gateway’s lifecycle. See Outbound Gateway for more information.

Conversion Errors in Message-Driven Endpoints

error-channel 现在用于转换错误。在以前的版本中,错误会引起事务回滚和消息重新传递。

The error-channel is now used for the conversion errors. In previous versions, they caused transaction rollback and message redelivery.

有关更多信息,请参见 Message-driven Channel AdapterInbound Gateway

See Message-driven Channel Adapter and Inbound Gateway for more information.

Default Acknowledge Mode

在使用隐式定义的 DefaultMessageListenerContainer 时,默认的 acknowledge 现在是 transacted。当使用此容器时,我们建议使用 transacted 以避免消息丢失。此默认值现在适用于消息驱动的入站适配器和入站网关。它已经是 JMS 支持的通道的默认值。

When using an implicitly defined DefaultMessageListenerContainer, the default acknowledge is now transacted. We recommend using transacted when using this container, to avoid message loss. This default now applies to the message-driven inbound adapter and the inbound gateway. It was already the default for JMS-backed channels.

有关更多信息,请参见 Message-driven Channel AdapterInbound Gateway

See Message-driven Channel Adapter and Inbound Gateway for more information.

Shared Subscriptions

我们为共享订阅(JMS 2.0)在消息驱动端点和 <int-jms:publish-subscribe-channel> 中添加了命名空间支持。以前,您必须将侦听器容器连接成 <bean/> 声明才能使用共享连接。

We added Namespace support for shared subscriptions (JMS 2.0) to message-driven endpoints and the <int-jms:publish-subscribe-channel>. Previously, you had to wire up listener containers as <bean/> declarations to use shared connections.

有关更多信息,请参见 JMS Support

See JMS Support for more information.

Conditional Pollers

现在,我们为动态轮询提供了更多的灵活性。

We now provide much more flexibility for dynamic polling.

有关更多信息,请参见 Conditional Pollers for Message Sources

See Conditional Pollers for Message Sources for more information.

AMQP Changes

本节介绍了 Spring Integration AMQP 功能的一些一般性更改。

This section describes general changes to the Spring Integration AMQP functionality.

Publisher Confirmations

<int-amqp:outbound-gateway> 现在支持 confirm-correlation-expressionconfirm-ack-channelconfirm-nack-channel 属性(这些属性的目的与 <int-amqp:outbound-channel-adapter> 类似)。

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>).

Correlation Data

对于出站通道适配器和入站网关,如果关联数据是 Message<?>,则它成为 ack 或 nack 通道上消息的基础,并附加其 header。以前,任何关联数据(包括 Message<?>)会作为 ack 或 nack 消息的负载返回。

For both the outbound channel adapter and the inbound gateway, if the correlation data is a Message<?>, it becomes the basis of the message on the ack or nack channel, with the additional header(s) added. Previously, any correlation data (including Message<?>) was returned as the payload of the ack or nack message.

Inbound Gateway Properties

<int-amqp:inbound-gateway> 现在公开 amqp-template 属性,允许对用于回复的 RabbitTemplate 的外部 bean 进行更多控制。您还可以提供自己的 AmqpTemplate 实现。此外,如果请求消息没有 replyTo 属性,可以使用 default-reply-to

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.

有关更多信息,请参见 AMQP Support

See AMQP Support for more information.

XPath Splitter Improvements

XPathMessageSplitter<int-xml:xpath-splitter>)现在允许配置内部 javax.xml.transform.Transformeroutput-properties,并支持用于 XPath 评估 org.w3c.dom.NodeList 结果的 Iterator 模式(默认值为 true)。

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.

有关更多信息,请参见 Splitting XML Messages

See Splitting XML Messages for more information.

HTTP Changes

本节介绍了 Spring Integration HTTP 功能的一些一般性更改。

This section describes general changes to the Spring Integration HTTP functionality.

CORS

HTTP 入站端点(<int-http:inbound-channel-adapter><int-http:inbound-gateway>)现在允许配置跨源资源共享 (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).

有关更多信息,请参见 Cross-origin Resource Sharing (CORS) Support

Inbound Gateway Timeout

您可以将 HTTP 入站网关配置为在其请求超时时返回指定的错误代码。现在默认为 500 Internal Server Error,而不是 200 OK

You can configure the HTTP inbound gate way to return a status code that you specify when a request times out. The default is now 500 Internal Server Error instead of 200 OK.

有关更多信息,请参见 Response Status Code

See Response Status Code for more information.

Form Data

我们为代理 multipart/form-data 请求添加了文档。有关更多信息,请参见 HTTP Support

We added documentation for proxying multipart/form-data requests. See HTTP Support for more information.

Gateway Changes

本部分介绍 Spring Integration Gateway 功能的一般更改。

This section describes general changes to the Spring Integration Gateway functionality.

[[gateway-methods-can-return-completablefuture<?>]]==== 网关方法可以返回 CompletableFuture<?>

[[gateway-methods-can-return-completablefuture<?>]] ==== Gateway Methods can Return CompletableFuture<?>

使用 Java 8 时,网关方法现在可以返回 CompletableFuture<?>。有关更多信息,请参见 CompletableFuture

When using Java 8, gateway methods can now return CompletableFuture<?>. See CompletableFuture for more information.

MessagingGateway Annotation

请求和回复超时属性现在是 String,而不是 Long,以允许使用属性占位符或 SpEL 配置。参见 @MessagingGateway Annotation

The request and reply timeout properties are now String instead of Long to allow configuration with property placeholders or SpEL. See @MessagingGateway Annotation.

Aggregator Changes

本部分介绍 Spring Integration 聚合器功能的一般更改。

This section describes general changes to the Spring Integration aggregator functionality.

Aggregator Performance

此版本包括一些针对聚合组件(聚合器、重新排序器等)的性能改进,在释放它们时更有效地从组中删除消息。已向消息存储中添加了新方法(removeMessagesFromGroup)。设置 removeBatchSize 属性(默认值为 100)以调整每个操作中删除的消息数量。目前,JDBC、Redis 和 MongoDB 消息存储支持此属性。

This release includes some performance improvements for aggregating components (aggregator, resequencer, and others), by more efficiently removing messages from groups when they are released. New methods (removeMessagesFromGroup) have been added to the message store. Set the removeBatchSize property (default: 100) to adjust the number of messages deleted in each operation. Currently, the JDBC, Redis, and MongoDB message stores support this property.

Output Message Group Processor

使用 ref 或内部 Bean 进行聚合时,你现在可以直接绑定 MessageGroupProcessor。此外,我们添加了一个 SimpleMessageGroupProcessor,它返回组中的消息集合。当输出处理器生成一系列 Message<?> 时,聚合器将这些消息逐个释放。配置 SimpleMessageGroupProcessor 使聚合器成为消息障碍,消息将在其中被保留,直到所有消息到达,然后逐个释放。有关更多信息,请参见 Aggregator

When using a ref or inner bean for the aggregator, you can now directly bind a MessageGroupProcessor. In addition, we added a SimpleMessageGroupProcessor that returns the collection of messages in the group. When an output processor produces a collection of Message<?>, the aggregator releases those messages individually. Configuring the SimpleMessageGroupProcessor makes the aggregator a message barrier, where messages are held up until they all arrive and are then released individually. See Aggregator for more information.

FTP and SFTP Changes

本部分介绍 Spring Integration FTP 和 SFTP 功能的一般更改。

This section describes general changes to the Spring Integration FTP and SFTP functionality.

Inbound Channel Adapters

现在可以在入站通道适配器上指定 remote-directory-expression,以在运行时确定目录。有关更多信息,请参阅 FTP/FTPS AdaptersSFTP Adapters

You can now specify a remote-directory-expression on the inbound channel adapters, to determine the directory at runtime. See FTP/FTPS Adapters and SFTP Adapters for more information.

Gateway Partial Results

当您使用 FTP 或 SFTP 出站网关对多个文件进行操作(使用 mget`和 `mput)时,可能会在完成请求的一部分后出现异常。如果出现这种情况,将引发包含部分结果的 PartialSuccessException。有关更多信息,请参阅 FTP Outbound GatewaySFTP Outbound Gateway

When you use FTP or SFTP outbound gateways to operate on multiple files (with mget and mput), an exception can occur after part of the request is completed. If such a condition occurs, a PartialSuccessException that contains the partial results is thrown. See FTP Outbound Gateway and SFTP Outbound Gateway for more information.

Delegating Session Factory

我们添加了一个委派会话工厂,它能够根据一些线程上下文值选择一个特定的会话工厂。

We added a delegating session factory, enabling the selection of a particular session factory based on some thread context value.

有关更多信息,请参阅 Delegating Session FactoryDelegating Session Factory

Default Sftp Session Factory

以前,DefaultSftpSessionFactory 无条件地允许连接到未知主机。现在这是可配置的(默认值为 false)。

Previously, the DefaultSftpSessionFactory unconditionally allowed connections to unknown hosts. This is now configurable (default: false).

除非 allowUnknownKeys 属性为 true(默认值为 false),否则该工厂现在需要一个配置好的 knownHosts 文件。

The factory now requires a configured knownHosts, file unless the allowUnknownKeys property is true (default: false).

有关更多信息,请参见xref:sftp/session-factory.adoc#sftp-unk-keys[allowUnknownKeys:置为`true`以允许连接到具有未知(或已更改)密钥的主机。

Message Session Callback

我们引入了 MessageSessionCallback<F, T>,以在 <int-(s)ftp:outbound-gateway/> 中使用 requestMessage 上下文执行任何自定义 Session 操作。

We introduced the MessageSessionCallback<F, T> to perform any custom Session operations with the requestMessage context in the <int-(s)ftp:outbound-gateway/>.

有关更多信息,请参阅 Using MessageSessionCallbackMessageSessionCallback

Websocket Changes

我们将对 WebSocketHandlerDecoratorFactory 的支持添加至 ServerWebSocketContainer,允许对内部 WebSocketHandler 进行链接定制。有关详细信息,请参见 WebSockets Namespace Support

We added WebSocketHandlerDecoratorFactory support to the ServerWebSocketContainer to allow chained customization for the internal WebSocketHandler. See WebSockets Namespace Support for more information.

Application Event Adapters changes

现在,ApplicationEvent`适配器可以将 `payload`用作 `event,以直接允许省略自定义 ApplicationEvent`扩展。为此,我们在 `<int-event:outbound-channel-adapter>`中引入了 `publish-payload`布尔属性。有关更多信息,请参阅 Spring `ApplicationEvent Support

The ApplicationEvent adapters can now operate with payload as an event to directly allow omitting custom ApplicationEvent extensions. For this purpose, we introduced the publish-payload boolean attribute has been introduced on the <int-event:outbound-channel-adapter>. See Spring ApplicationEvent Support for more information.