Changes between 2.1 and 2.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
2.2 版本增加了许多新组件。
Version 2.2 added a number of new components.
RedisStore
Inbound and Outbound Channel Adapters
Spring Integration现在具有`RedisStore`输入和输出信道适配器,让你可以将`Message`有效负载写入和读出Redis集合。更多信息,请参见RedisStore Outbound Channel Adapter和Redis Store Inbound Channel Adapter。
Spring Integration now has RedisStore
Inbound and Outbound Channel Adapters, letting you write and read Message
payloads to and from Redis collections.
For more information, see RedisStore Outbound Channel Adapter and Redis Store Inbound Channel Adapter.
MongoDB Inbound and Outbound Channel Adapters
Spring Integration现在具有MongoDB入站和出站通道适配器,让你可以将`Message`有效负载写入和读出MongoDB文档存储器。更多信息,请参见MongoDB Outbound Channel Adapter和MongoDB Inbound Channel Adapter。
Spring Integration now has MongoDB inbound and outbound channel adapters, letting you write and read Message
payloads to and from a MongoDB document store.
For more information, see MongoDB Outbound Channel Adapter and MongoDB Inbound Channel Adapter.
JPA Endpoints
Spring Integration 现在包含用于检索和存储 JPA 实体对象 Java 持久化 API (JPA) 的组件。JPA 适配器包括以下组件:
Spring Integration now includes components for the Java Persistence API (JPA) for retrieving and persisting JPA entity objects. The JPA Adapter includes the following components:
如需了解更多信息,请参阅 JPA Support。
For more information, see JPA Support.
General Changes
本节介绍了从 2.1 版本到 2.2 版本的一般变更。
This section describes general changes from version 2.1 to version 2.2.
Spring 3.1 Used by Default
Spring Integration 现在使用 Spring 3.1。
Spring Integration now uses Spring 3.1.
Adding Behavior to Endpoints
一段时间以来已经可以使用将 <advice-chain/>
添加到轮询器的功能。但由此添加的行为影响了整个集成流程。它没有涉及为单个端点添加(例如)重试的功能。2.2 版本引入了 <request-handler-advice-chain/>
用于许多端点。
The ability to add an <advice-chain/>
to a poller has been available for some time.
However, the behavior added by this affects the entire integration flow.
It did not address the ability to add (for example) retry to an individual endpoint.
The 2.2 release introduced the <request-handler-advice-chain/>
to many endpoints.
此外,我们为此目的添加了三类标准建议:
In addition, we added three standard advice classes for this purpose:
-
MessageHandlerRetryAdvice
-
MessageHandlerCircuitBreakerAdvice
-
ExpressionEvaluatingMessageHandlerAdvice
如需了解更多信息,请参见 Adding Behavior to Endpoints。
For more information, see Adding Behavior to Endpoints.
Transaction Synchronization and Pseudo Transactions
轮询器现在可以参与 Spring 的事务同步功能。这允许同步操作,例如由入站通道适配器重命名文件,具体取决于事务是提交还是回滚。
Pollers can now participate in Spring’s Transaction Synchronization feature. This allows for synchronizing such operations as renaming files by an inbound channel adapter, depending on whether the transaction commits or rolls back.
此外,您可以通过 PseudoTransactionManager
在没有 “real” 事务存在的情况下启用此功能。
In addition, you can enable these features when no “real” transaction is present, by means of a PseudoTransactionManager
.
更多信息,请参见Transaction Synchronization。
For more information, see Transaction Synchronization.
File Adapter: Improved File Overwrite and Append Handling
使用文件出站通道适配器或文件出站网关后,你可以使用新的 mode
属性。在 Spring Integration 2.2 之前,目标文件被替换,当它们存在时。现在,你可以指定以下选项:
When using the file outbound channel adapter or the file outbound gateway, you can use a new mode
property.
Prior to Spring Integration 2.2, target files were replaced when they existed.
Now you can specify the following options:
-
REPLACE
(default) -
APPEND
-
FAIL
-
IGNORE
For more information, see Dealing with Existing Destination Files.
Reply-Timeout Added to More Outbound Gateways
XML 命名空间支持为以下出站网关添加 reply-timeout 属性:
The XML Namespace support adds the reply-timeout attribute to the following outbound gateways:
-
AMQP Outbound Gateway
-
File Outbound Gateway
-
FTP Outbound Gateway
-
SFTP Outbound Gateway
-
WS Outbound Gateway
Spring-AMQP 1.1
Spring Integration 现在使用 Spring AMQP 1.1。这使 Spring Integration 应用程序中可以使用多项功能,包括以下功能:
Spring Integration now uses Spring AMQP 1.1. This enables several features to be used within a Spring Integration application, including the following:
-
A fixed reply queue for the outbound gateway
-
HA (mirrored) queues
-
Publisher confirmations
-
Returned messages
-
Support for dead letter exchanges and dead letter queues
JDBC Support - Stored Procedures Components
SpEL Support
使用 Spring Integration JDBC 适配器的存储过程组件后,你现在可以通过使用 Spring 表达式语言 (SpEL) 来提供存储过程名称或存储功能名称。
When using the stored procedure components of the Spring Integration JDBC Adapter, you can now provide stored procedure names or stored function names by using the Spring Expression Language (SpEL).
这样做可让你指定在运行时调用的存储过程。例如,你可以提供你要通过消息头执行的存储过程名称。如需了解更多信息,请参见 Stored Procedures。
Doing so lets you specify the stored procedures to be invoked at runtime. For example, you can provide stored procedure names that you would like to execute through message headers. For more information, see Stored Procedures.
JDBC Support: Outbound Gateway
使用 JDBC 出站网关时,不再强制要求更新查询。你现在可以通过将请求消息用作参数源,仅提供选择查询。
When you use the JDBC outbound gateway, the update query is no longer mandatory. You can now provide only a select query by using the request message as a source of parameters.
JDBC Support: Channel-specific Message Store Implementation
我们添加了一个新的消息通道特定的消息存储实现,使用特定于数据库的SQL查询提供了一个更具可扩展性的解决方案。更多信息,请参见Backing Message Channels。
We added a new message channel-specific message store implementation, providing a more scalable solution using database-specific SQL queries. For more information, see Backing Message Channels.
Orderly Shutdown
我们向 IntegrationMBeanExporter
添加了一个称为 stopActiveComponents()
的方法。它允许 Spring Integration 应用程序有序关闭,不允许某些适配器接收新入站消息,并等待一段时间以允许进行中的消息完成。
We added a method called stopActiveComponents()
to the IntegrationMBeanExporter
.
It allows a Spring Integration application to be shut down in an orderly manner, disallowing new inbound messages to certain adapters and waiting for some time to allow in-flight messages to complete.
JMS Outbound Gateway Improvements
你现在可以配置 JMS 出站网关,以使用 MessageListener
容器来接收答复。这样做可以提高网关的性能。
You can now configure the JMS outbound gateway to use a MessageListener
container to receive replies.
Doing so can improve performance of the gateway.
ObjectToJsonTransformer
默认情况下,ObjectToJsonTransformer`现在将 `content-type`标头设置为 `application/json
。如需了解更多信息,请参见 Transformer。
By default, the ObjectToJsonTransformer
now sets the content-type
header to application/json
.
For more information, see Transformer.
HTTP Support
不再默认启用 HTTP 上的 Java 序列化。之前,在 Serializable
对象上设置 expected-response-type
时,Accept
头未正确设置。我们更新了 SerializingHttpMessageConverter
,以便将 Accept
头设置为 application/x-java-serialized-object
。但是,由于这可能会与现有应用程序不兼容,我们决定不再将此转换器自动添加到 HTTP 端点。
Java serialization over HTTP is no longer enabled by default.
Previously, when setting an expected-response-type
on a Serializable
object, the Accept
header was not properly set up.
We updated the SerializingHttpMessageConverter
to set the Accept
header to application/x-java-serialized-object
.
However, because this could cause incompatibility with existing applications, we decided to no longer automatically add this converter to the HTTP endpoints.
如果你希望使用 Java 序列化,你需要通过使用 message-converters
属性(当你使用 XML 配置时)或通过使用 setMessageConverters()
方法(在 Java 中)将 SerializingHttpMessageConverter
添加到相应的端点。
If you wish to use Java serialization, you need to add the SerializingHttpMessageConverter
to the appropriate endpoints by using the message-converters
attribute (when you use XML configuration) or by using the setMessageConverters()
method (in Java).
或者,你可能希望考虑使用 JSON。通过将 Jackson
添加到类路径即可启用它。
Alternatively, you may wish to consider using JSON instead.
It is enabled by having Jackson
on the classpath.