Changes Between 2.2 and 3.0

有关可能影响您的应用程序的重要更改,请参阅 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

3.0 版本添加了多个新组件。

Version 3.0 added a number of new components.

HTTP Request Mapping

现在,HTTP 模块为入境终结点提供了强大的请求映射支持。我们将 UriPathHandlerMapping 类替换为 IntegrationRequestMappingHandlerMapping,该类在应用程序上下文中以 integrationRequestMappingHandlerMapping 的 Bean 名称注册。在解析 HTTP 入境终结点时,一个新的 IntegrationRequestMappingHandlerMapping Bean 也会被注册,或者一个现有的 Bean 会被复用。要实现灵活的请求映射配置,Spring Integration 为 <http:inbound-channel-adapter/><http:inbound-gateway/> 提供了 <request-mapping/> 子元素。现在,两个 HTTP 入境终结点都完全基于 Spring MVC 3.1 中引入的请求映射基础设施。例如,单个入境终结点上支持多条路径。有关更多信息,请参阅 HTTP Namespace Support

The HTTP module now provides powerful request mapping support for inbound endpoints. We replaced the UriPathHandlerMapping class with IntegrationRequestMappingHandlerMapping, which is registered under the bean name of integrationRequestMappingHandlerMapping in the application context. Upon parsing of the HTTP inbound endpoint, either a new IntegrationRequestMappingHandlerMapping bean is registered or an existing bean is reused. To achieve flexible request mapping configuration, Spring Integration provides the <request-mapping/> child element for <http:inbound-channel-adapter/> and the <http:inbound-gateway/>. Both HTTP inbound endpoints are now fully based on the request mapping infrastructure that was introduced with Spring MVC 3.1. For example, multiple paths are supported on a single inbound endpoint. For more information see HTTP Namespace Support.

Spring Expression Language (SpEL) Configuration

我们添加了一个新的 IntegrationEvaluationContextFactoryBean 来允许配置自定义 PropertyAccessor 实现以及函数,以便在整个框架中的 SpEL 表达式中使用。有关更多信息,请参阅 Spring Expression Language (SpEL)

We added a new IntegrationEvaluationContextFactoryBean to allow configuration of custom PropertyAccessor implementations and functions for use in SpEL expressions throughout the framework. For more information, see Spring Expression Language (SpEL).

SpEL Functions Support

为了使用静态`Method`函数来自定义 SpEL EvaluationContext,我们引入了`<spel-function/>`组件。我们还添加了两个内置函数:#jsonPath`和#xpath`。有关更多信息,请参阅SpEL Functions

To customize the SpEL EvaluationContext with static Method functions, we introduced the <spel-function/> component. We also added two built-in functions: #jsonPath and #xpath. For more information, see SpEL Functions.

SpEL PropertyAccessors Support

为了使用`PropertyAccessor`实现来自定义 SpEL EvaluationContext,我们添加了`<spel-property-accessors/>`组件。有关更多信息,请参阅Property Accessors

To customize the SpEL EvaluationContext with PropertyAccessor implementations, we added the <spel-property-accessors/> component. For more information, see Property Accessors.

Redis: New Components

我们添加了一个新的基于 Redis 的 MetadataStore实现。您可以使用`RedisMetadataStore`来维护`MetadataStore`在应用程序重新启动期间的状态。此新的`MetadataStore`实现可以与适配器一起使用,例如:

We added a new Redis-based MetadataStore implementation. You can use the RedisMetadataStore to maintain the state of a MetadataStore across application restarts. This new MetadataStore implementation can be used with adapters, such as:

  • Twitter inbound adapters

  • Feed inbound channel adapter

我们添加了新的基于队列的组件。我们添加了 <int-redis:queue-inbound-channel-adapter/><int-redis:queue-outbound-channel-adapter/> 组件,用于分别对 Redis list 执行“右弹”和“左推”操作。

We added new queue-based components. We added the <int-redis:queue-inbound-channel-adapter/> and <int-redis:queue-outbound-channel-adapter/> components to perform 'right pop' and 'left push' operations, respectively, on a Redis List.

有关更多信息,“see Redis Support”。

For more information, “see Redis Support”.

Header Channel Registry

您现在可以指示框架将答复通道和错误通道存储在注册表中以供以后解析。对于可能会丢失`replyChannel`或`errorChannel`的情况(例如,在序列化消息时),这非常有用。有关更多信息,请参阅Header Enricher

You can now instruct the framework to store reply channels and error channels in a registry for later resolution. This is useful for cases where the replyChannel or errorChannel might be lost (for example, when serializing a message). See Header Enricher for more information.

MongoDB support: New ConfigurableMongoDbMessageStore

除了现有的 eMongoDbMessageStore 之外,我们还引入了新的 ConfigurableMongoDbMessageStore。这为 MongoDB 提供了一个更强大、更灵活的 MessageStore 实现。它与现有存储不向后兼容,但我们建议将其用于新应用程序。现有应用程序可以使用它,但旧存储中的消息不可用。有关更多信息,请参阅 MongoDb Support

In addition to the existing eMongoDbMessageStore, we introduced a new ConfigurableMongoDbMessageStore. This provides a more robust and flexible implementation of MessageStore for MongoDB. It does not have backward compatibility with the existing store, but we recommend using it for new applications. Existing applications can use it, but messages in the old store are not available. See MongoDb Support for more information.

Syslog Support

在 2.2 SyslogToMapTransformer 的基础上,Spring Integration 3.0 引入了 UDPTCP 入站通道适配器,这些适配器专为接收 SYSLOG 消息而特别定制。有关更多信息,请参阅 Syslog Support

Building on the 2.2 SyslogToMapTransformer, Spring Integration 3.0 introduces UDP and TCP inbound channel adapters especially tailored for receiving SYSLOG messages. For more information, see Syslog Support.

tail Support

我们添加了文件入站通道适配器,这些适配器使用`tail`命令在文本文件末尾添加行时生成消息。请参阅'tail’ing Files

We added file inbound channel adapters that use the tail command to generate messages when lines are added to the end of text files. See 'tail’ing Files.

JMX Support

我们添加了 <int-jmx:tree-polling-channel-adapter/>。此适配器查询 JMX MBean 树,并发送一条消息,其有效负载是与查询匹配的对象图。默认情况下,MBean 被映射到原语和简单对象(例如 MapList 和数组)。例如,它允许简单地转换为 JSON。

We added <int-jmx:tree-polling-channel-adapter/>. This adapter queries the JMX MBean tree and sends a message with a payload that is the graph of objects that match the query. By default, the MBeans are mapped to primitives and simple Objects (such as Map, List, and arrays). It permits simple transformation to, for example, JSON.

IntegrationMBeanExporter 现在允许通过 naming-strategy 属性配置自定义 ObjectNamingStrategy

The IntegrationMBeanExporter now allows the configuration of a custom ObjectNamingStrategy by using the naming-strategy attribute.

有关更多信息,请参阅 JMX Support

For more information, see JMX Support.

TCP/IP Connection Events and Connection Management

当连接打开或关闭,或发生异常时,TcpConnection 实例现在会发出 ApplicationEvent 实例(特别是 TcpConnectionEvent 实例)。此更改使应用程序能够使用正常的 Spring ApplicationListener 机制了解 TCP 连接的变更。

TcpConnection instances now emit ApplicationEvent instances (specifically TcpConnectionEvent instances) when connections are opened or closed or when an exception occurs. This change lets applications be informed of changes to TCP connections by using the normal Spring ApplicationListener mechanism.

我们已将 AbstractTcpConnection 重命名为 TcpConnectionSupport。此类的子类自定义连接可以使用其方法发布事件。类似地,我们已将 AbstractTcpConnectionInterceptor 重命名为 TcpConnectionInterceptorSupport

We renamed AbstractTcpConnection to TcpConnectionSupport. Custom connections that are subclasses of this class can use its methods to publish events. Similarly, we renamed AbstractTcpConnectionInterceptor to TcpConnectionInterceptorSupport.

此外,我们还添加了 <int-ip:tcp-connection-event-inbound-channel-adapter/>。默认情况下,此适配器将所有 TcpConnectionEvent 实例发送到 Channel

In addition, we added <int-ip:tcp-connection-event-inbound-channel-adapter/>. By default, this adapter sends all TcpConnectionEvent instances to a Channel.

此外,TCP 连接工厂现在提供了一个名为 getOpenConnectionIds() 的新方法,该方法返回一个列表,其中包含所有打开连接的标识符。它可以让应用程序广播到所有打开的连接,还有其他用途。

Further, the TCP connection factories now provide a new method called getOpenConnectionIds(), which returns a list of identifiers for all open connections. It lets applications broadcast to all open connections, among other uses.

最后,连接工厂还提供了一个名为 closeConnection(String connectionId) 的新方法,该方法可以让应用程序通过其 ID 显式关闭连接。

Finally, the connection factories also provide a new method called closeConnection(String connectionId), which lets applications explicitly close a connection by using its ID.

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

For more information see TCP Connection Events.

Inbound Channel Adapter Script Support

<int:inbound-channel-adapter/>`现在支持使用<expression/>`和`<script/>`子元素来创建一个`MessageSource`。请参阅Channel Adapter Expressions and Scripts

The <int:inbound-channel-adapter/> now supports using <expression/> and <script/> child elements to create a MessageSource. See Channel Adapter Expressions and Scripts.

Content Enricher: Headers Enrichment Support

内容充实器现在为`<header/>`子元素提供配置,以使用来自底层消息流的答复消息中的标头来充实出站消息。有关更多信息,请参阅Payload Enricher

The content enricher now provides configuration for <header/> child elements, to enrich the outbound message with headers based on the reply message from the underlying message flow. For more information see Payload Enricher.

General Changes

本节描述从版本 2.2 到版本 3.0 的一般性更改。

This section describes general changes from version 2.2 to version 3.0.

Message ID Generation

以前,消息 ID 是使用 JDK `UUID.randomUUID()`方法生成的。在此版本中,默认机制已更改为使用更高效、显著更快的算法。此外,我们还添加了更改用于生成消息 ID 的策略的功能。有关更多信息,请参阅Message ID Generation

Previously, message IDs were generated by using the JDK UUID.randomUUID() method. With this release, the default mechanism has been changed to use a more efficient and significantly faster algorithm. In addition, we added the ability to change the strategy used to generate message IDs. For more information see Message ID Generation.

“<gateway>” Changes

您现在可以为所有网关方法设置通用标题,我们还添加了更多选项,以便在消息中添加有关调用哪个方法的信息。

You can now set common headers across all gateway methods, and we added more options for adding information to the message about which method was invoked.

您现在可以完全定制以何种方式将网关方法调用映射到消息。

You can now entirely customize the way that gateway method calls are mapped to messages.

GatewayMethodMetadata 现在是公共类。它让您能够从 Java 中以编程方式配置 GatewayProxyFactoryBean

The GatewayMethodMetadata is now a public class. It lets you programmatically configure the GatewayProxyFactoryBean from Java.

有关更多信息,请参阅 Messaging Gateways

For more information, see Messaging Gateways.

HTTP Endpoint Changes

  • Outbound Endpoint encode-uri: <http:outbound-gateway/> and <http:outbound-channel-adapter/> now provide an encode-uri attribute to allow disabling the encoding of the URI object before sending the request.

  • Inbound Endpoint merge-with-default-converters: <http:inbound-gateway/> and <http:inbound-channel-adapter/> now have a merge-with-default-converters attribute to include the list of default HttpMessageConverter instances after the custom message converters.

  • If-Modified-Since and If-Unmodified-Since HTTP Headers: Previously, the If-Modified-Since and If-Unmodified-Since HTTP headers were incorrectly processed within from and to HTTP headers mapped in the DefaultHttpHeaderMapper. Now, in addition to correcting that issue, DefaultHttpHeaderMapper provides date parsing from formatted strings for any HTTP headers that accept date-time values.

  • Inbound Endpoint Expression Variables: In addition to the existing #requestParams and #pathVariables, the <http:inbound-gateway/> and <http:inbound-channel-adapter/> now support additional useful variables: #matrixVariables, #requestAttributes, #requestHeaders, and #cookies. These variables are available in both payload and header expressions.

  • Outbound Endpoint 'uri-variables-expression': HTTP outbound endpoints now support the uri-variables-expression attribute to specify an Expression to evaluate a Map for all URI variable placeholders within URL template. This allows selection of a different map of expressions based on the outgoing message.

有关更多信息,请参阅 HTTP Support

For more information, see HTTP Support.

Jackson Support (JSON)

  • A new abstraction for JSON conversion has been introduced. Implementations for Jackson 1.x and Jackson 2 are currently provided, with the version being determined by presence on the classpath. Previously, only Jackson 1.x was supported.

  • The ObjectToJsonTransformer and JsonToObjectTransformer now emit/consume headers containing type information.

有关更多信息,请参阅 “JSON Transformers” 中的 Transformer

For more information, see “JSON Transformers” in Transformer.

Chain Elements id Attribute

以前,<chain> 中元素的 id 属性被忽略,并且在某些情况下不允许。现在,id 属性允许用于 <chain> 中的所有元素。链元素的 bean 名称是周围链的 id 和元素自身的 id 的组合。例如:'myChain$child.myTransformer.handler'。有关更多信息,请参阅 Message Handler Chain

Previously, the id attribute for elements within a <chain> was ignored and, in some cases, disallowed. Now, the id attribute is allowed for all elements within a <chain>. The bean names of chain elements is a combination of the surrounding chain’s id and the id of the element itself. For example: 'myChain$child.myTransformer.handler'. For more information see, Message Handler Chain.

Aggregator 'empty-group-min-timeout' property

`AbstractCorrelatingMessageHandler`提供了一个名为`empty-group-min-timeout`的新属性,允许空组到期以比部分组到期更长的计划来运行。直到至少过了此毫秒数才修改空组,否则它们不会从`MessageStore`中删除。有关更多信息,请参阅Configuring an Aggregator with XML

The AbstractCorrelatingMessageHandler provides a new property called empty-group-min-timeout to allow empty group expiry to run on a longer schedule than expiring partial groups. Empty groups are not removed from the MessageStore until they have not been modified for at least this number of milliseconds. For more information, see Configuring an Aggregator with XML.

Persistent File List Filters (file, (S)FTP)

现在可以使用新的 FileListFilter 实现,这些实现使用持久 MetadataStore。可以在系统重新启动后使用这些实现来防止重复的文件。有关更多信息,请参阅 Reading FilesFTP Inbound Channel AdapterSFTP Inbound Channel Adapter

New FileListFilter implementations that use a persistent MetadataStore are now available. You can use these to prevent duplicate files after a system restart. See Reading Files, FTP Inbound Channel Adapter, and SFTP Inbound Channel Adapter for more information.

Scripting Support: Variables Changes

我们为脚本组件引入了一个新的 variables 属性。此外,现在允许将变量绑定用于内联脚本。有关更多信息,请参阅 Groovy supportScripting Support

We introduced a new variables attribute for scripting components. In addition, variable bindings are now allowed for inline scripts. See Groovy support and Scripting Support for more information.

Direct Channel Load Balancing configuration

以前,在通道的 dispatcher 子元素上配置 LoadBalancingStrategy 时,唯一可用的选项是使用预定义的值枚举,这让开发者无法设置 LoadBalancingStrategy 的自定义实现。您现在可以使用 load-balancer-ref 提供 LoadBalancingStrategy 的自定义实现的引用。有关详细信息,请参阅 xref:channel/implementations.adoc#channel-implementations-directchannel[DirectChannel

Previously, when configuring LoadBalancingStrategy on the channel’s dispatcher child element, the only available option was to use a pre-defined enumeration of values which did not let developers set a custom implementation of the LoadBalancingStrategy. You can now use load-balancer-ref to provide a reference to a custom implementation of the LoadBalancingStrategy. For more information, see DirectChannel.

PublishSubscribeChannel Behavior

以前,发送到没有任何订阅者的 <publish-subscribe-channel/> 会返回 false 结果。如果与 MessagingTemplate 结合使用,这会导致抛出异常。现在,PublishSubscribeChannel 有一个称为 minSubscribers(默认值:0)的属性。如果消息发送到至少最小数量的订阅者,则发送操作被认为是成功的(即使该数量为零)。如果应用程序希望在这种情况下收到异常,请将最小订阅者设置为至少 1。

Previously, sending to a <publish-subscribe-channel/> that had no subscribers would return a false result. If used in conjunction with a MessagingTemplate, this would result in an exception being thrown. Now, the PublishSubscribeChannel has a property called minSubscribers (default: 0). If the message is sent to at least the minimum number of subscribers, the send operation is deemed to be successful (even if the number is zero). If an application expects to get an exception under these conditions, set the minimum subscribers to at least 1.

FTP, SFTP and FTPS Changes

默认情况下,FTP、SFTP 和 FTPS 终结点不再缓存会话。

The FTP, SFTP and FTPS endpoints no longer cache sessions by default.

我们从所有终结点中删除了已弃用的 cached-sessions 属性。以前,此属性的值控制的嵌入式缓存机制无法限制高速缓存的大小,高速缓存可能会无限增长。版本 2.1 引入了 CachingConnectionFactory,它已成为缓存会话的首选方式(现在也是唯一方式)。

We removed the deprecated cached-sessions attribute from all endpoints. Previously, the embedded caching mechanism controlled by this attribute’s value did not provide a way to limit the size of the cache, which could grow indefinitely. Release 2.1 introduced CachingConnectionFactory, and it became the preferred (and is now the only) way to cache sessions.

现在,CachingConnectionFactory 提供了一种新方法:resetCache()。此方法立即关闭空闲会话并导致正在使用的会话在返回到缓存时关闭。

CachingConnectionFactory now provides a new method: resetCache(). This method immediately closes idle sessions and causes in-use sessions to be closed as and when they are returned to the cache.

DefaultSftpSessionFactory(与 CachingSessionFactory 结合使用)现在支持通过单个 SSH 连接多路复用通道(仅限 SFTP)。

The DefaultSftpSessionFactory (in conjunction with a CachingSessionFactory) now supports multiplexing channels over a single SSH connection (SFTP Only).

FTP, SFTP and FTPS Inbound Adapters

以前,没有办法覆盖用于处理从远程服务器检索的文件的默认过滤器。filter 特性确定要检索的文件,但 FileReadingMessageSource 使用 AcceptOnceFileListFilter。这意味着,如果检索到与先前复制的文件同名的文件的副本,适配器将不会发送任何消息。

Previously, there was no way to override the default filter used to process files retrieved from a remote server. The filter attribute determines which files are retrieved, but the FileReadingMessageSource uses an AcceptOnceFileListFilter. This means that, if a new copy of a file is retrieved with the same name as a previously copied file, no message was sent from the adapter.

在此版本中,新特性 local-filter 允许您覆盖默认过滤器(例如,使用 AcceptAllFileListFilter 或其他自定义过滤器)。

With this release, a new attribute local-filter lets you override the default filter (for example, with an AcceptAllFileListFilter or some other custom filter).

如果您希望在 JVM 执行期间保持 AcceptOnceFileListFilter 的行为,现在您可以配置保留状态的自定义过滤器,也许在文件系统中。

If you want the behavior of the AcceptOnceFileListFilter to be maintained across JVM executions, you can now configure a custom filter that retains state, perhaps on the file system.

入站通道适配器现在支持 preserve-timestamp 特性,该特性将本地文件修改时间戳设置为来自服务器的时间戳(默认值为:false)。

Inbound channel adapters now support the preserve-timestamp attribute, which sets the local file modified timestamp to the timestamp from the server (default: false).

FTP, SFTP, and FTPS Gateways

网关现在支持 mv 命令,允许重命名远程文件。

The gateways now support the mv command, enabling the renaming of remote files.

网关现在支持递归 lsmget 命令,允许检索远程文件树。

The gateways now support recursive ls and mget commands, enabling the retrieval of a remote file tree.

网关现在支持 putmput 命令,允许将文件发送到远程服务器。

The gateways now support put and mput commands, enabling sending files to the remote server.

现在支持特性 local-filename-generator-expression,允许在检索过程中命名本地文件。默认情况下,使用与远程文件相同的名字。

The local-filename-generator-expression attribute is now supported, enabling the naming of local files during retrieval. By default, the same name as the remote file is used.

现在支持特性 local-directory-expression,允许在检索过程中命名本地目录(基于远程目录)。

The local-directory-expression attribute is now supported, enabling the naming of local directories during retrieval (based on the remote directory).

Remote File Template

FTP 和 SFTP 模块使用的 Session 实现上提供了一个新的更高级别的抽象(RemoteFileTemplate)。虽然它内部由端点使用,但您也可以以编程方式使用此抽象。与所有 Spring *Template 实现一样,它可靠地关闭底层会话同时允许低级访问会话。

A new higher-level abstraction (RemoteFileTemplate) is provided over the Session implementations used by the FTP and SFTP modules. While it is used internally by endpoints, you can also use this abstraction programmatically. Like all Spring *Template implementations, it reliably closes the underlying session while allowing low level access to the session.

有关更多信息,请参阅 FTP/FTPS AdaptersSFTP Adapters

For more information, see FTP/FTPS Adapters and SFTP Adapters.

'requires-reply' Attribute for Outbound Gateways

所有出站网关(如 <jdbc:outbound-gateway/><jms:outbound-gateway/>)都设计用于“请求-答复”场景。外部服务应该有答复并将其发布到 reply-channelreplyChannel 消息头。不过,在某些情况下外部系统可能不总是返回结果(例如,在 SELECT 以空 ResultSet 结束时的 <jdbc:outbound-gateway/> 或者单向 web 服务)。因此,开发人员需要一种选项来配置是否需要答复。为此,我们为出站网关组件引入了 requires-reply 特性。在大多数情况下,requires-reply 的默认值为 true。如果没有结果,将抛出 ReplyRequiredException。将该值更改为 false 意味着,如果外部服务不返回任何内容,消息流将在那一刻结束,类似于出站通道适配器。

All outbound gateways (such as <jdbc:outbound-gateway/> or <jms:outbound-gateway/>) are designed for 'request-reply' scenarios. A response is expected from the external service and is published to the reply-channel or the replyChannel message header. However, there are some cases where the external system might not always return a result (for example, a <jdbc:outbound-gateway/> when a SELECT ends with an empty ResultSet or perhaps a one-way web service). Consequently, developers needed an option to configure whether or not a reply is required. For this purpose, we introduced the requires-reply attribute for outbound gateway components. In most cases, the default value for requires-reply is true. If there is no result, a ReplyRequiredException is thrown. Changing the value to false means that, if an external service does not return anything, the message flow ends at that point, similar to an outbound channel adapter.

WebService 出站网关有一个名为 ignore-empty-responses 的附加属性。它用于将一个空的 String 响应视为未收到任何响应。默认情况下,它是 true,但您可以将其设置为 false 以允许应用程序在响应消息有效载荷中接收一个空的 String。当该属性为 true 时,一个空字符串将被视为 requires-reply 属性中没有响应。默认情况下,对于 WebService 出站网关,requires-reply 为 false。

The WebService outbound gateway has an additional attribute called ignore-empty-responses. It is used to treat an empty String response as if no response were received. By default, it is true, but you can set it to false to allow the application to receive an empty String in the reply message payload. When the attribute is true, an empty string is treated as no response for the purposes of the requires-reply attribute. By default, requires-reply is false for the WebService outbound gateway.

请注意,以前曾存在 requiresReply 特性,但在 AbstractReplyProducingMessageHandler 中设置为 false,并且没有办法使用 XML 命名空间为出站网关对其进行配置。

Note that the requiresReply property was previously present but set to false in the AbstractReplyProducingMessageHandler, and there was no way to configure it on outbound gateways by using the XML namespace.

以前,没有收到响应的网关会自动结束流(带有 DEBUG 日志消息)。默认情况下,通过本更改,大多数网关现在会抛出一个异常。要恢复到以前的行为,请将 requires-reply 设置为 false

Previously, a gateway receiving no reply would silently end the flow (with a DEBUG log message). By default, with this change, an exception is now thrown by most gateways. To revert to the previous behavior, set requires-reply to false.

AMQP Outbound Gateway Header Mapping

以前,<int-amqp:outbound-gateway/> 在调用消息转换器之前映射头,并且转换器可以覆盖头,例如 content-type。出站适配器在转换之后映射头,这意味着使用来自出站 Messagecontent-type 之类的头(如果存在)。

Previously, the <int-amqp:outbound-gateway/> mapped headers before invoking the message converter, and the converter could overwrite headers such as content-type. The outbound adapter maps the headers after the conversion, which means headers like content-type from the outbound Message (if present) are used.

从这个版本开始,网关现在在消息转换后映射头,这与适配器一致。如果您的应用程序依赖于之前的行为(其中转换器的头覆盖映射的头),则需要过滤那些头(在消息到达网关之前)或适当地设置它们。受 SimpleMessageConverter 影响的头是 content-typecontent-encoding。自定义消息转换器可能设置其他头。

Starting with this release, the gateway now maps the headers after the message conversion, consistent with the adapter. If your application relies on the previous behavior (where the converter’s headers overrode the mapped headers), you either need to filter those headers (before the message reaches the gateway) or set them appropriately. The headers affected by the SimpleMessageConverter are content-type and content-encoding. Custom message converters may set other headers.

Stored Procedure Components Improvements

对于标准 CallableStatement.getObject 方法不支持的更复杂的特定于数据库的类型,我们在具有 OUT 方向的 <sql-parameter-definition/> 元素中引入了两个新的附加特性:

For more complex database-specific types not supported by the standard CallableStatement.getObject method, we introduced two new additional attributes to the <sql-parameter-definition/> element with OUT-direction:

  • type-name

  • return-type

存储过程入站通道适配器 <returning-resultset/> 子元素的 row-mapper 特性现在支持对 RowMapper bean 定义的引用。以前,它只包含一个类名(仍然支持)。

The row-mapper attribute of the stored procedure inbound channel adapter <returning-resultset/> child element now supports a reference to a RowMapper bean definition. Previously, it contained only a class name (which is still supported).

有关更多信息,请参阅 Stored Procedures

For more information, see Stored Procedures.

Web Service Outbound URI Configuration

Web 服务出站网关“uri”属性现在支持 Spring Web 服务支持的所有 URI 方案的`<uri-variable/>`替换。有关更多信息,请参阅Outbound URI Configuration

The web service outbound gateway 'uri' attribute now supports <uri-variable/> substitution for all URI schemes supported by Spring Web Services. For more information, see Outbound URI Configuration.

Redis Adapter Changes

Redis 入站通道适配器现在可以使用“null”值作为“serializer”属性,原始数据作为消息有效负载。

The Redis inbound channel adapter can now use a null value for the serializer property, with the raw data being the message payload.

Redis 出站通道适配器现在具有“topic-expression”属性,用于在运行时确定“Message”的 Redis 主题。

The Redis outbound channel adapter now has the topic-expression property to determine the Redis topic for the Message at runtime.

Redis 入站通道适配器还具有“topic-patterns”属性,除了现有的“topics”属性外。

The Redis inbound channel adapter, in addition to the existing topics attribute, now has the topic-patterns attribute.

有关更多信息,请参阅 Redis Support

For more information, see Redis Support.

Advising Filters

以前,当 <filter/> 具有 <request-handler-advice-chain/> 时,放弃操作都在建议链范围内执行(包括 discard-channel 中的任何下游流)。过滤器元素现在具有一个名为 discard-within-advice 的属性(默认值:true),以允许在建议链完成后执行丢弃操作。请参阅 Advising Filters

Previously, when a <filter/> had a <request-handler-advice-chain/>, the discard action was all performed within the scope of the advice chain (including any downstream flow on the discard-channel). The filter element now has an attribute called discard-within-advice (default: true) to allow the discard action to be performed after the advice chain completes. See Advising Filters.

Advising Endpoints using Annotations

请求处理程序建议链现在可以通过注释进行配置。请参阅 Advising Endpoints Using Annotations

Request handler advice chains can now be configured using annotations. See Advising Endpoints Using Annotations.

ObjectToStringTransformer Improvements

此转换器现在可以正确地将 byte[]char[] 有效负载转换为 String。如需了解更多信息,请参阅 Transformer

This transformer now correctly transforms byte[] and char[] payloads to String. For more information, see Transformer.

JPA Support Changes

要持久保留或合并的有效负载现在可以为 java.lang.Iterable 类型。

Payloads to persist or merge can now be of type java.lang.Iterable.

在这种情况下,由“Iterable”返回的每个对象都被视为一个实体,并使用底层的“EntityManager”进行持久化或合并。迭代器返回的空值将被忽略。

In that case, each object returned by the Iterable is treated as an entity and persisted or merged by using the underlying EntityManager. Null values returned by the iterator are ignored.

在执行持久化操作后,JPA 适配器现在具有附加属性,可以从关联的持久化上下文中选择性地刷新和清除实体。

The JPA adapters now have additional attributes to optionally flush and clear entities from the associated persistence context after performing persistence operations.

检索网关没有机制来指定要检索的第一条记录,这是一个常见的用例。检索网关现在支持通过将`first-result`和`first-result-expression`属性添加到网关定义来指定此参数。有关更多信息,请参阅Retrieving Outbound Gateway

Retrieving gateways had no mechanism to specify the first record to be retrieved, which is a common use case. The retrieving gateways now support specifying this parameter by adding the first-result and first-result-expression attributes to the gateway definition. For more information, see Retrieving Outbound Gateway.

JPA 检索网关和入站适配器现在具有一个属性,可以将结果集中的最大结果数指定为表达式。此外,我们引入了“max-results”属性来替换已被弃用的“max-number-of-results”。“max-results”和“max-results-expression”用于分别提供结果集中的最大结果数或计算最大结果数的表达式。

The JPA retrieving gateway and inbound adapter now have an attribute to specify the maximum number of results in a result set as an expression. In addition, we introduced the max-results attribute to replace max-number-of-results, which has been deprecated. max-results and max-results-expression are used to provide the maximum number of results or an expression to compute the maximum number of results, respectively, in the result set.

如需了解更多信息,请参阅 JPA Support

For more information, see JPA Support.

Delayer: delay expression

以前,<delayer> 提供了一个 delay-header-name 属性来在运行时确定延迟值。在复杂的情况下,<delayer> 之前必须使用 <header-enricher>。Spring Integration 3.0 引入了 expression 属性和 expression 子元素,用于动态延迟确定。delay-header-name 属性现已弃用,因为您可以指定 expression 中的标头评估。此外,我们还引入了 ignore-expression-failures 来控制表达式评估失败时的行为。如需了解更多信息,请参阅 Delayer

Previously, the <delayer> provided a delay-header-name attribute to determine the delay value at runtime. In complex cases, the <delayer> had to be preceded with a <header-enricher>. Spring Integration 3.0 introduced the expression attribute and expression child element for dynamic delay determination. The delay-header-name attribute is now deprecated, because you can specify the header evaluation in the expression. In addition, we introduced the ignore-expression-failures to control the behavior when an expression evaluation fails. For more information, see Delayer.

JDBC Message Store Improvements

Spring Integration 3.0 添加了一组针对 MySQL 版本 5.6.4 及更高版本的 DDL 脚本。现在 MySQL 支持小数秒,因此在从基于 MySQL 的消息存储进行轮询时可以改善 FIFO 顺序。有关更多信息,请参阅The Generic JDBC Message Store

Spring Integration 3.0 adds a new set of DDL scripts for MySQL version 5.6.4 and higher. Now MySQL supports fractional seconds and is thus improving the FIFO ordering when polling from a MySQL-based message store. For more information, see The Generic JDBC Message Store.

IMAP Idle Connection Exceptions

先前,如果 IMAP 空闲连接失败,则会记录下来,但没有机制通知应用程序。此类异常现在会生成`ApplicationEvent`实例。应用程序可以使用 <int-event:inbound-channel-adapter> 或配置为接收`ImapIdleExceptionEvent`(或其超类之一)的任何`ApplicationListener`来获取这些事件。

Previously, if an IMAP idle connection failed, it was logged, but there was no mechanism to inform an application. Such exceptions now generate ApplicationEvent instances. Applications can obtain these events by using an <int-event:inbound-channel-adapter> or any ApplicationListener configured to receive an ImapIdleExceptionEvent (or one of its super classes).

Message Headers and TCP

现在,TCP 连接工厂能够配置灵活的机制,通过 TCP 传输所选头(以及有效负载)。新的 TcpMessageMapper 能够选择标头,您需要配置适当的序列化器或反序列化器,将结果 Map 写入到 TCP 流。我们添加了 MapJsonSerializer 作为一个便利机制,以便通过 TCP 传输头和有效负载。更多信息,请参阅 Transferring Headers

The TCP connection factories now enable the configuration of a flexible mechanism to transfer selected headers (as well as the payload) over TCP. A new TcpMessageMapper enables the selection of the headers, and you need to configure an appropriate serializer or deserializer to write the resulting Map to the TCP stream. We added a MapJsonSerializer as a convenient mechanism to transfer headers and payload over TCP. For more information, see Transferring Headers.

JMS Message Driven Channel Adapter

以前,在配置 <message-driven-channel-adapter/> 时,如果你想使用一个特定 TaskExecutor,你需要声明一个容器 Bean,并通过设置 container 属性,将其提供给适配器。我们添加了 task-executor,使其可以直接在适配器上进行设置。这除了已经具有的一些其他容器属性之外。

Previously, when configuring a <message-driven-channel-adapter/>, if you wished to use a specific TaskExecutor, you had to declare a container bean and provide it to the adapter by setting the container attribute. We added the task-executor, letting it be set directly on the adapter. This is in addition to several other container attributes that were already available.

XsltPayloadTransformer

您现在可以通过设置 transformer-factory-class 属性指定转换器工厂类名称。请参阅 XsltPayloadTransformer

You can now specify the transformer factory class name by setting the transformer-factory-class attribute. See XsltPayloadTransformer.