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

3.0 与 4.0 之间的变更

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

新组件

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

MQTT 通道适配器

MQTT 通道适配器(此前在 Spring Integration Extensions 仓库中提供)现在已作为标准 Spring Integration 分发的一部分。请参见 MQTT 支持spring-doc.cadn.net.cn

@EnableIntegration

我们添加了 @EnableIntegration 注解,以便在使用 @Configuration 类时能够声明标准的 Spring Integration Bean。 有关更多信息,请参阅 注解支持spring-doc.cadn.net.cn

@IntegrationComponentScan

我们添加了 @IntegrationComponentScan 注解以允许对 Spring Integration 特定组件进行类路径扫描。 有关更多信息,请参阅 注解支持spring-doc.cadn.net.cn

"@启用消息历史"

您现在可以在 @Configuration 类中使用 @EnableMessageHistory 注解来启用消息历史记录。 此外,JMX MBean 可以修改消息历史记录设置。 同时,MessageHistory 可以跟踪为带注解端点(例如 @ServiceActivator@Splitter 等)自动创建的 MessageHandler 实例。 更多信息,请参见 消息历史记录spring-doc.cadn.net.cn

@MessagingGateway

您现在可以使用 @MessagingGateway 注解来配置消息网关接口。 它是 <int:gateway/> XML 元素的对应物。 更多信息,请参阅 @MessagingGateway 注解spring-doc.cadn.net.cn

Spring Boot@EnableAutoConfiguration

除了前面提到的 @EnableIntegration 注解外,我们还引入了一个钩子,允许 Spring Integration 的基础设施 Bean 使用 Spring Boot 的 @EnableAutoConfiguration 注解进行配置。 更多信息,请参阅 Spring Boot 参考指南中的“自动配置”spring-doc.cadn.net.cn

@GlobalChannelInterceptor

除了上述提到的 @EnableIntegration 注解外,我们还引入了 @GlobalChannelInterceptor 注解。 更多信息,请参见 注解支持spring-doc.cadn.net.cn

@IntegrationConverter

我们引入了 @IntegrationConverter 注解,作为 <int:converter/> 组件的类比。 更多信息,请参见 注解支持spring-doc.cadn.net.cn

@EnablePublisher

我们添加了@EnablePublisher注解,以便为@Publisher注解指定default-publisher-channel。 有关更多信息,请参阅注解支持spring-doc.cadn.net.cn

Redis 通道消息存储

我们添加了一个 Redis MessageGroupStore,该配置针对用于持久化 QueueChannel 的场景进行了优化。 更多信息,请参阅 Redis 通道消息存储spring-doc.cadn.net.cn

我们已添加 Redis ChannelPriorityMessageStore。 您可以使用它按优先级检索消息。 更多信息,请参见 Redis 通道消息存储spring-doc.cadn.net.cn

MongoDB 通道消息存储

MongoDB 支持现在提供了 MongoDbChannelMessageStore,这是一个特定于通道的 MessageStore 实现。 使用 priorityEnabled = true,您可以在 <int:priority-queue> 元素中使用它来实现持久化消息的优先级轮询。 更多信息请参见 MongoDB 通道消息存储spring-doc.cadn.net.cn

@EnableIntegrationMBeanExport

您现在可以在 @Configuration 类中使用 @EnableIntegrationMBeanExport 注解来启用 IntegrationMBeanExporter。 更多信息,请参阅 MBean Exporterspring-doc.cadn.net.cn

ChannelSecurityInterceptorFactoryBean

ChannelSecurityInterceptorFactoryBean 现在支持为使用 @Configuration 类消息通道配置 Spring Security。 有关更多信息,请参阅 Spring Integration 中的安全性spring-doc.cadn.net.cn

Redis 命令网关

Redis 支持现在提供了 <outbound-gateway> 组件,用于通过 RedisConnection#execute 方法执行通用 Redis 命令。 有关更多信息,请参见 Redis 出站命令网关spring-doc.cadn.net.cn

RedisLockRegistry

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.spring-doc.cadn.net.cn

@Poller

基于注解的消息配置现在可以拥有 poller 属性。 这意味着使用 @ServiceActivator@Aggregator 等注解的方法现在可以使用一个引用 PollableChannelinputChannel。 更多信息,请参见 注解支持spring-doc.cadn.net.cn

@InboundChannelAdapterSmartLifecyclefor 注解端点

我们添加了 @InboundChannelAdapter 方法注解。 它相当于 <int:inbound-channel-adapter> XML 组件。 此外,所有消息传递注解现在都提供 SmartLifecycle 选项。 有关更多信息,请参阅 注解支持spring-doc.cadn.net.cn

Twitter 搜索出站网关

我们新增了一个 Twitter 端点:<int-twitter-search-outbound-gateway/>。 与每次使用相同搜索查询进行轮询的搜索入站适配器不同,出站网关支持按需自定义查询。 更多信息,请参见 Spring Integration Social Twitterspring-doc.cadn.net.cn

@BridgeFrom@BridgeTo注解

我们介绍了 @BridgeFrom@BridgeTo @Bean 方法注解,用于在 MessageChannel 类中标记 @Configuration bean。 更多信息,请参见 注解支持spring-doc.cadn.net.cn

元消息注解

消息注解(@ServiceActivator@Router@MessagingGateway 及其他)现在可配置为用户自定义消息注解的元注解。 此外,用户自定义注解可以具有相同的属性(inputChannel@PollerautoStartup 及其他)。 更多信息,请参见 注解支持spring-doc.cadn.net.cn

常规变更

本节描述了从 3.0 版本到 4.0 版本的一般性变更。spring-doc.cadn.net.cn

需要 Spring Framework 4.0

我们将核心消息抽象(MessageMessageChannel及其他)移至 Spring Framework spring-messaging 模块。 直接在代码中引用这些类的开发者需要做出更改,具体操作请参考3.0 到 4.0 迁移指南的第一部分。spring-doc.cadn.net.cn

XPath Header Enricher 的头部类型

我们为 <int-xml:xpath-header-enricher> 的子元素 header 引入了 header-type 属性。 此属性提供了目标类型(XPath 表达式求值的结果将转换为此类型)。 更多信息请参见 XPath 头部增强器spring-doc.cadn.net.cn

对象转 JSON 转换器:节点结果

我们为 <int:object-to-json-transformer> 引入了 result-type 属性。 此属性提供了将对象映射为 JSON 时结果的目标类型。 它支持 STRING(默认值)和 NODE。 更多信息请参见 自 3.0 版本起,Spring Integration 还提供了一种内置的 #xpath SpEL 函数,可用于表达式中。spring-doc.cadn.net.cn

JMS 标头映射

DefaultJmsHeaderMapper现在将传入的JMSPriority头映射到Spring Integration priority头。 此前,priority仅用于出站消息。 更多信息,请参阅将消息头映射到JMS消息及从JMS消息映射spring-doc.cadn.net.cn

JMS 出站通道适配器

JMS 出站通道适配器现在支持 session-transacted 属性(默认值:false)。 此前,您必须注入自定义的 JmsTemplate 才能使用事务。 请参阅 出站通道适配器spring-doc.cadn.net.cn

JMS 入站通道适配器

JMS 入站通道适配器现在支持 session-transacted 属性(默认值:false)。 此前,若要使用事务,您必须注入自定义的 JmsTemplate。 该适配器允许在 acknowledgeMode 中使用 'transacted',这是不正确的且无法正常工作。 此值不再被允许。 请参见 入站通道适配器spring-doc.cadn.net.cn

数据类型通道

您现在可以指定一个 MessageConverter,用于在数据通道中将负载(必要时)转换为接受的 datatype 实例之一。 更多信息,请参见 数据通道配置spring-doc.cadn.net.cn

更简单的重试建议配置

我们添加了对配置 RequestHandlerRetryAdvice 的简化命名空间支持。 更多信息,请参阅 配置重试建议spring-doc.cadn.net.cn

关联端点:基于时间的发布策略

我们为 <int:aggregator><int:resequencer> 添加了互斥的 group-timeoutgroup-timeout-expression 属性。 这些属性允许强制完成部分 MessageGroup,前提是 ReleaseStrategy 不释放组且在指定时间内没有进一步的消息到达。 更多信息,请参阅 使用 XML 配置聚合器spring-doc.cadn.net.cn

Redis 元数据存储

The RedisMetadataStore 现在实现了 ConcurrentMetadataStore,使其能够在多个应用实例或服务器环境中用于 AbstractPersistentAcceptOnceFileListFilter 实现。 更多信息,请参见 Redis 元数据存储读取文件FTP 入站通道适配器 以及 SFTP 入站通道适配器spring-doc.cadn.net.cn

JdbcChannelMessageStorePriorityChannel

T`JdbcChannelMessageStore`现在实现了PriorityCapableChannelMessageStore,使其可以作为message-store引用来用于priority-queue实例。 更多信息,请参阅支持消息通道spring-doc.cadn.net.cn

AMQP 端点交付模式

Spring AMQP 默认会在消息代理上创建持久消息。 您可以通过设置 amqp_deliveryMode 标头或自定义映射器来覆盖此行为。 我们在适配器中添加了便捷的 default-delivery-mode 属性,以便更轻松地配置此重要设置。 更多信息,请参见 出站通道适配器出站网关spring-doc.cadn.net.cn

FTP 超时

The DefaultFtpSessionFactory 现在公开了 connectTimeoutdefaultTimeoutdataTimeout 属性,无需通过子类化工厂来设置这些公共属性。 The postProcess* 方法仍然可用于更高级的配置。 有关更多信息,请参见 FTP Session Factoryspring-doc.cadn.net.cn

推特:StatusUpdatingMessageHandler

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

JPA 检索网关:id-expression

我们引入了 id-expression 属性用于 <int-jpa:retrieving-outbound-gateway>,以执行 EntityManager.find(Class entityClass, Object primaryKey)。 有关更多信息,请参阅 检索出站网关spring-doc.cadn.net.cn

TCP 反序列化事件

当一个标准反序列化器在将输入流解码为消息时遇到问题,它现在会发出TcpDeserializationExceptionEvent,让应用程序能够检查异常发生时的数据。 有关更多信息,请参阅TCP 连接事件spring-doc.cadn.net.cn

消息注解在@Bean定义

您现在可以在@Bean类中的@Configuration定义上配置消息注解(@ServiceActivator@Router@InboundChannelAdapter及其他)。 如需更多信息,请参阅注解支持spring-doc.cadn.net.cn