Changes between 3.0 and 4.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

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

Version 4.0 added a number of new components.

MQTT Channel Adapters

MQTT 通道适配器(以前可在 Spring Integration Extensions 储藏库中使用)现在可作为常规 Spring Integration 分发的组成部分获得。请参阅 MQTT Support

The MQTT channel adapters (previously available in the Spring Integration Extensions repository) are now available as part of the normal Spring Integration distribution. See MQTT Support.

@EnableIntegration

我们添加了 `@EnableIntegration`注释,以便在使用 `@Configuration`类时声明标准 Spring Integration bean。有关更多信息,请参阅 Annotation Support

We added the @EnableIntegration annotation to permit declaration of standard Spring Integration beans when using @Configuration classes. See Annotation Support for more information.

@IntegrationComponentScan

我们添加了 `@IntegrationComponentScan`注释,以便针对特定于 Spring Integration 的组件进行类路径扫描。有关更多信息,请参阅 Annotation Support

We added the @IntegrationComponentScan annotation to permit classpath scanning for Spring Integration-specific components. See Annotation Support for more information.

“@EnableMessageHistory”

您现在可以通过 @Configuration`类中的 `@EnableMessageHistory`注释启用消息历史记录。此外,JMX MBean 可以修改消息历史记录设置。此外,`MessageHistory`可以跟踪带注释端点的自动创建的 `MessageHandler`实例(例如 `@ServiceActivator、`@Splitter`等)。有关更多信息,请参阅 Message History

You can now enable message history with the @EnableMessageHistory annotation in a @Configuration class. In addition, a JMX MBean can modify the message history settings. Also, MessageHistory can track auto-created MessageHandler instances for annotated endpoints (such as @ServiceActivator, @Splitter, and others). For more information, see Message History.

@MessagingGateway

你现在可以使用 @MessagingGateway 注释配置消息网关接口。它是 <int:gateway/> XML 元素的模拟。更多信息,请参见 xref:gateway.adoc#messaging-gateway-annotation[@MessagingGateway 注释。

You can now configure messaging gateway interfaces with the @MessagingGateway annotation. It is an analogue of the <int:gateway/> XML element. For more information, see @MessagingGateway Annotation.

Spring Boot @EnableAutoConfiguration

除了前面提到的 @EnableIntegration 注释之外,我们还引入了一个钩子,以允许 Spring Integration 基础设施 Bean 使用 Spring Boot 的 @EnableAutoConfiguration 注释进行配置。更多信息,请参见 Spring Boot 参考指南中的 link:https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-auto-configuration.html[“Auto-configuration”。

As well as the @EnableIntegration annotation mentioned earlier, we introduced a hook to allow the Spring Integration infrastructure beans to be configured with Spring Boot’s @EnableAutoConfiguration annotation. For more information, see “Auto-configuration” in the Spring Boot Reference Guide.

@GlobalChannelInterceptor

除了上面提到的 `@EnableIntegration`注释外,我们还引入了 `@GlobalChannelInterceptor`注释。有关更多信息,请参阅 Annotation Support

As well as the @EnableIntegration annotation mentioned above, we introduced the @GlobalChannelInterceptor annotation. For more information, see Annotation Support.

@IntegrationConverter

我们引入了 `@IntegrationConverter`注释,作为 `<int:converter/>`组件的类比。有关更多信息,请参阅 Annotation Support

We introduced the @IntegrationConverter annotation as an analogue of the <int:converter/> component. For more information, see Annotation Support.

@EnablePublisher

我们添加了 @EnablePublisher`注释,以允许为 `@Publisher`注释指定 `default-publisher-channel。有关更多信息,请参阅 Annotation Support

We added the @EnablePublisher annotation to allow the specification of a default-publisher-channel for @Publisher annotations. See Annotation Support for more information.

Redis Channel Message Stores

我们增加了一个适用于在支持持久性的 QueueChannel`时优化的 Redis `MessageGroupStore。有关更多信息,请参阅 Redis Channel Message Stores

We added a Redis MessageGroupStore that is optimized for use when backing a QueueChannel for persistence. For more information, see Redis Channel Message Stores.

我们增加了一个 Redis ChannelPriorityMessageStore。您可以使用它按优先级检索消息。有关更多信息,请参阅 Redis Channel Message Stores

We added a Redis ChannelPriorityMessageStore. You can use it to retrieve messages by priority. For more information, see Redis Channel Message Stores.

MongodDB Channel Message Store

MongoDB 支持现在提供了 MongoDbChannelMessageStore,它是一项针对特定通道的 MessageStore`实现。使用 `priorityEnabled = true,您可以在 `<int:priority-queue>`元素中使用它来实现持久化消息的优先级排序轮询。有关更多信息,请参阅 MongoDB Channel Message Store

The MongoDB support now provides the MongoDbChannelMessageStore, which is a channel-specific MessageStore implementation. With priorityEnabled = true, you can use it in <int:priority-queue> elements to achieve priority order polling of persisted messages. For more information see MongoDB Channel Message Store.

@EnableIntegrationMBeanExport

现在,您可以在 @Configuration`类中通过 `@EnableIntegrationMBeanExport`注释启用 `IntegrationMBeanExporter。有关更多信息,请参阅 MBean Exporter

You can now enable the IntegrationMBeanExporter with the @EnableIntegrationMBeanExport annotation in a @Configuration class. For more information, see MBean Exporter.

ChannelSecurityInterceptorFactoryBean

`ChannelSecurityInterceptorFactoryBean`现在支持为使用 `@Configuration`类的消息通道配置 Spring Security。有关更多信息,请参阅 Security in Spring Integration

ChannelSecurityInterceptorFactoryBean now supports configuration of Spring Security for message channels that use @Configuration classes. For more information, see Security in Spring Integration.

Redis Command Gateway

Redis 支持现在提供了 `<outbound-gateway>`组件,以通过使用 `RedisConnection#execute`方法执行通用 Redis 命令。有关更多信息,请参阅 Redis Outbound Command Gateway

The Redis support now provides the <outbound-gateway> component to perform generic Redis commands by using the RedisConnection#execute method. For more information, see Redis Outbound Command Gateway.

RedisLockRegistry

现在,`RedisLockRegistry`可用于支持多应用程序实例和服务器之间可见的全局锁。这些可与多个应用程序实例中的信息处理程序聚合配合使用,如此将仅在一个实例上执行组释放。有关更多信息,请参阅 Redis Lock RegistryAggregator

The RedisLockRegistry is now available to support global locks visible to multiple application instances and servers. These can be used with aggregating message handlers across multiple application instances such that group release occurs on only one instance. For more information, see Redis Lock Registry and Aggregator.

@Poller

基于注释的消息传递配置现在可以包含 poller 特性。这意味着注释为 @ServiceActivator@Aggregator 及类似注释的方法现在可以使用一个 inputChannel,该方法是对 PollableChannel 的引用。有关详细信息,请参阅 Annotation Support

Annotation-based messaging configuration can now have a poller attribute. This means that methods annotated with @ServiceActivator, @Aggregator, and similar annotations can now use an inputChannel that is a reference to a PollableChannel. For more information, see Annotation Support.

@InboundChannelAdapter and SmartLifecycle for Annotated Endpoints

我们添加了 @InboundChannelAdapter 方法注释。它是 <int:inbound-channel-adapter> XML 组件的对应项。此外,现在所有消息传递注释都提供了 SmartLifecycle 选项。有关详细信息,请参阅 Annotation Support

We added the @InboundChannelAdapter method annotation. It is an analogue of the <int:inbound-channel-adapter> XML component. In addition, all messaging annotations now provide SmartLifecycle options. For more information, see Annotation Support.

Twitter Search Outbound Gateway

我们添加了一个新的 Twitter 端点:<int-twitter-search-outbound-gateway/>。与搜索入站适配器(每次使用相同的搜索查询进行轮询)不同,出站网关允许按需进行自定义查询。有关更多信息,请参见 Spring Integration Social Twitter

We added a new twitter endpoint: <int-twitter-search-outbound-gateway/>. Unlike the search inbound adapter, which polls by using the same search query each time, the outbound gateway allows on-demand customized queries. For more information, see Spring Integration Social Twitter.

@BridgeFrom and @BridgeTo Annotations

我们引入了 @BridgeFrom@BridgeTo @Bean 方法注释,在 @Configuration 类中标记 MessageChannel Bean。有关详细信息,请参阅 Annotation Support

We introduced @BridgeFrom and @BridgeTo @Bean method annotations to mark MessageChannel beans in @Configuration classes. For more information, see Annotation Support.

Meta-messaging Annotations

现在可以将消息传递注释 (@ServiceActivator@Router@MessagingGateway 等) 配置为用户定义的消息传递注释的元注释。此外,用户定义的注释可以具有相同的特性 (inputChannel@PollerautoStartup 等)。有关详细信息,请参阅 Annotation Support

Messaging annotations (@ServiceActivator, @Router, @MessagingGateway, and others) can now be configured as meta-annotations for user-defined messaging annotations. In addition, the user-defined annotations can have the same attributes (inputChannel, @Poller, autoStartup, and others). For more information, see Annotation Support.

General Changes

本部分描述了从版本 3.0 到版本 4.0 的一般更改。

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

Requires Spring Framework 4.0

我们将核心消息抽象(MessageMessageChannel 和其他)移至 Spring Framework `spring-messaging`模块。直接在代码中引用这些类的开发人员需要进行更改,如 3.0 to 4.0 Migration Guide的第一部分中所述。

We moved the core messaging abstractions (Message, MessageChannel, and others) to the Spring Framework spring-messaging module. Developers who reference these classes directly in their code need to make changes, as described in the first section of the 3.0 to 4.0 Migration Guide.

Header Type for XPath Header Enricher

我们在 <int-xml:xpath-header-enricher>header 子元素中引入了 header-type 特性。此特性提供了标题值的目标类型(XPath 表达式求值的结果转换成的类型)。有关详细信息,请参阅 XPath Header Enricher

We introduced the header-type attribute for the header child element of the <int-xml:xpath-header-enricher>. This attribute provides the target type for the header value (to which the result of the XPath expression evaluation is converted). For more information see XPath Header Enricher.

Object To JSON Transformer: Node Result

我们为 <int:object-to-json-transformer> 引入了 result-type 属性。此属性提供映射对象到 JSON 的结果的目标类型。它支持 STRING(默认)和 NODE。有关更多信息,请参见 Since version 3.0, Spring Integration also provides a built-in #xpath SpEL function for use in expressions.

We introduced the result-type attribute for the <int:object-to-json-transformer>. This attribute provides the target type for the result of mapping an object to JSON. It supports STRING (the default) and NODE. For more information see Since version 3.0, Spring Integration also provides a built-in #xpath SpEL function for use in expressions..

JMS Header Mapping

DefaultJmsHeaderMapper 现在将传入 JMSPriority 头映射到 Spring Integration priority 头。以前,priority 仅考虑用于出站消息。有关更多信息,请参见 Mapping Message Headers to and from JMS Message

The DefaultJmsHeaderMapper now maps an incoming JMSPriority header to the Spring Integration priority header. Previously, priority was only considered for outbound messages. For more information, see Mapping Message Headers to and from JMS Message.

JMS Outbound Channel Adapter

JMS 出站通道适配器现在支持 session-transacted 属性(默认:false)。以前,您必须注入自定义 JmsTemplate 才能使用事务。请参见 Outbound Channel Adapter

The JMS outbound channel adapter now supports the session-transacted attribute (default: false). Previously, you had to inject a customized JmsTemplate to use transactions. See Outbound Channel Adapter.

JMS Inbound Channel Adapter

JMS 入站通道适配器现在支持 session-transacted 属性(默认:false)。以前,您必须注入自定义 JmsTemplate 才能使用事务。该适配器允许在 acknowledgeMode 中使用“已处理”,这是不正确的,也不会起作用。该值不再允许。请参见 Inbound Channel Adapter

The JMS inbound channel adapter now supports the session-transacted attribute (default: false). Previously, you had to inject a customized JmsTemplate to use transactions. The adapter allowed 'transacted' in the acknowledgeMode, which was incorrect and didn’t work. This value is no longer allowed. See Inbound Channel Adapter.

Datatype Channels

您现在可以指定 MessageConverter,用于在数据类型通道中将有效负载(如果需要)转换为可接受的 datatype 实例之一。有关更多信息,请参见 Datatype Channel Configuration

You can now specify a MessageConverter to be used when converting (if necessary) payloads to one of the accepted datatype instances in a Datatype channel. For more information, see Datatype Channel Configuration.

Simpler Retry Advice Configuration

我们添加了简化的命名空间支持,用于配置 RequestHandlerRetryAdvice。有关更多信息,请参见 Configuring the Retry Advice

We added simplified namespace support to configure a RequestHandlerRetryAdvice. For more information, see Configuring the Retry Advice.

Correlation Endpoint: Time-based Release Strategy

我们将互斥的 group-timeoutgroup-timeout-expression 属性添加到 <int:aggregator><int:resequencer> 中。这些属性允许强制完成部分 MessageGroup,前提是 ReleaseStrategy 不释放组,并且在指定的时间内没有收到进一步的消息。有关更多信息,请参见 Configuring an Aggregator with XML

We added the mutually exclusive group-timeout and group-timeout-expression attributes to <int:aggregator> and <int:resequencer>. These attributes allow forced completion of a partial MessageGroup, provided the ReleaseStrategy does not release a group and no further messages arrive within the time specified. For more information, see Configuring an Aggregator with XML.

Redis Metadata Store

RedisMetadataStore 现在实现了 ConcurrentMetadataStore,使其能够在多个应用程序实例或服务器环境中的 AbstractPersistentAcceptOnceFileListFilter 实现中使用。有关更多信息,请参见 Redis Metadata StoreReading FilesFTP Inbound Channel AdapterSFTP Inbound Channel Adapter

The RedisMetadataStore now implements ConcurrentMetadataStore, letting it be used, for example, in an AbstractPersistentAcceptOnceFileListFilter implementation in a multiple application instance or server environment. For more information, see Redis Metadata Store, Reading Files, FTP Inbound Channel Adapter, and SFTP Inbound Channel Adapter.

JdbcChannelMessageStore and PriorityChannel

T`JdbcChannelMessageStore` 现在实现了 PriorityCapableChannelMessageStore,使其可以用作 priority-queue 实例的 message-store 引用。有关更多信息,请参见 Backing Message Channels

T`JdbcChannelMessageStore` now implements PriorityCapableChannelMessageStore, letting it be used as a message-store reference for priority-queue instances. For more information, see Backing Message Channels.

AMQP Endpoints Delivery Mode

默认情况下,Spring AMQP 会在代理上创建持久性消息。您可以通过设置 amqp_deliveryMode 标题或自定义映射程序来覆盖此行为。我们向适配器添加了便捷的 default-delivery-mode 特性,以更轻松地配置此重要设置。有关详细信息,请参阅 Outbound Channel AdapterOutbound Gateway

Spring AMQP, by default, creates persistent messages on the broker. You can override this behavior by setting the amqp_deliveryMode header or customizing the mappers. We added a convenient default-delivery-mode attribute to the adapters to provide easier configuration of this important setting. For more information, see Outbound Channel Adapter and Outbound Gateway.

FTP Timeouts

现在,DefaultFtpSessionFactory 公开了 connectTimeoutdefaultTimeoutdataTimeout 属性,从而避免了对工厂进行子类化以设置这些通用属性的需要。仍然提供了 postProcess* 方法用于更高级的配置。有关详细信息,请参阅 FTP Session Factory

The DefaultFtpSessionFactory now exposes the connectTimeout, defaultTimeout, and dataTimeout properties, avoiding the need to subclass the factory to set these common properties. The postProcess* methods are still available for more advanced configuration. See FTP Session Factory for more information.

Twitter: StatusUpdatingMessageHandler

StatusUpdatingMessageHandler (<int-twitter:outbound-channel-adapter>) 现在支持 tweet-data-expression 属性,用于构建 org.springframework.social.twitter.api.TweetData 对象以更新时间轴状态。例如,此功能允许附加图片。有关更多信息,请参见 Spring Integration Social Twitter

The StatusUpdatingMessageHandler (<int-twitter:outbound-channel-adapter>) now supports the tweet-data-expression attribute to build a org.springframework.social.twitter.api.TweetData object for updating the timeline status. This feature allows, for example, attaching an image. See Spring Integration Social Twitter for more information.

JPA Retrieving Gateway: id-expression

我们为 <int-jpa:retrieving-outbound-gateway> 引入了 id-expression 属性,用于执行 EntityManager.find(Class entityClass, Object primaryKey)。有关更多信息,请参见 Retrieving Outbound Gateway

We introduced the id-expression attribute for <int-jpa:retrieving-outbound-gateway> to perform EntityManager.find(Class entityClass, Object primaryKey). See Retrieving Outbound Gateway for more information.

TCP Deserialization Events

当标准反序列化程序之一在对消息的输入流进行解码时遇到问题时,它现在会发出 TcpDeserializationExceptionEvent,让应用程序在遇到异常时检查数据。有关更多信息,请参见 TCP Connection Events

When one of the standard deserializers encounters a problem decoding the input stream to a message, it now emits a TcpDeserializationExceptionEvent, letting applications examine the data at the point at which the exception occurred. See TCP Connection Events for more information.

Messaging Annotations on @Bean Definitions

您现在可以在 @Configuration 类中的 @Bean 定义中配置消息传递注释 (@ServiceActivator@Router@InboundChannelAdapter 等)。有关详细信息,请参阅 Annotation Support

You can now configure messaging annotations (@ServiceActivator, @Router, @InboundChannelAdapter, and others) on @Bean definitions in @Configuration classes. For more information, see Annotation Support.