|
如需使用最新稳定版本,请使用 Spring Integration 7.0.4! |
4.1 与 4.2 之间的变更
新组件
版本4.2添加了许多新组件。
主要管理/JMX 重构
我们新增了一个 MetricsFactory 策略接口。
此变更连同 JMX 和管理基础设施中的其他变更,提供了对管理配置和运行时性能的更多控制能力。
然而,这对(某些)用户环境有一些重要的影响。
MongoDB 元数据存储
MongoDbMetadataStore 现已可用。
有关更多信息,请参阅 MongoDB 元数据存储。
SecuredChannel 注解
我们介绍了 @SecuredChannel 注解,以取代已弃用的 ChannelSecurityInterceptorFactoryBean。
如需更多信息,请参阅 Spring Integration 中的安全性。
SecurityContext传播
我们介绍了SecurityContextPropagationChannelInterceptor用于将SecurityContext传播从一个消息流的线程传递到另一个线程。
更多信息,请参见Spring Integration 中的安全性。
文件分割器
在 4.1.2 版本中,我们添加了 FileSplitter,它可以将文本文件按行分割。
现在它在 int-file: 命名空间中得到了全面支持。
有关更多信息,请参阅 文件分割器。
Zookeeper 支持
我们为该框架添加了 Zookeeper 支持,以协助在集群或多主机环境中运行。 此变更影响以下功能:
-
ZookeeperMetadataStore -
ZookeeperLockRegistry -
Zookeeper 领导权
有关更多信息,请参见 Zookeeper 支持。
线程屏障
一个新的线程 <int:barrier/> 组件已可用,它允许线程挂起直到发生某个异步事件。
有关更多信息,请参阅 线程屏障 (Thread Barrier)。
STOMP 支持
我们已将 STOMP 支持添加到框架中,作为一对入站和出站通道适配器。 有关更多信息,请参阅 STOMP 支持。
编解码器
引入了一个新的Codec抽象,用于将对象编码和解码为byte[]。
我们添加了一个使用 Kryo 的实现。
我们还添加了基于编解码器的转换器和消息转换器。
有关更多信息,请参阅Codec。
消息 PreparedStatement Setter
对于 MessagePreparedStatementSetter(<int-jdbc:outbound-gateway> 和 <int-jdbc:outbound-channel-adapter>)的 JdbcMessageHandler,新增了一个 requestMessage 上下文的替代方案,用于通过 SqlParameterSourceFactory 向 PreparedStatement 填充参数,该方案使用新的 MessagePreparedStatementSetter 函数式接口回调。
有关更多信息,请参阅 出站通道适配器。
常规变更
本节描述了从版本 4.1 到版本 4.2 的通用变更。
文件更改
有关这些更改的更多信息,请参阅 文件支持。
追加新行
The <int-file:outbound-channel-adapter> and <int-file:outbound-gateway> 现在支持一个 append-new-line 属性。
如果设置为 true,则在写入消息后会在文件末尾追加新行。
该属性的默认值为 false。
类包变更
我们将 ScatterGatherHandler 类从 org.springframework.integration.handler 移动到了 org.springframework.integration.scattergather。
TCP 变更
本节介绍 Spring Integration TCP 功能的一般变更。
TCP 序列化器
TCP Serializers不再flush()OutputStream。
现在由TcpNxxConnection类完成。
如果您直接在代码中使用序列化器,可能需要flush()OutputStream。
服务器套接字异常
TcpConnectionServerExceptionEvent 个实例现在会在 TCP 服务器套接字上发生意外异常时发布(也已添加到 4.1.3 和 4.0.7)。
有关更多信息,请参阅 TCP 连接事件。
TCP 服务器端口
如果您配置一个 TCP 服务器套接字工厂以监听随机端口,现在可以通过使用 getPort() 获取操作系统实际选择的端口。
getServerSocketAddress() 也可用。
有关更多信息,请参阅"TCP 连接工厂"。
TCP 网关远程超时
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 具有相同的值,而后者具有完全不同的含义。
有关更多信息,请参阅 .TCP 出站网关属性。
TCP SSLSession 可用于标题映射
TcpConnection 实现现在支持 getSslSession(),以便您从会话中提取信息并添加到消息头中。
有关更多信息,请参阅 IP 消息头。
TCP 事件
每当发生关联异常(例如向不存在的套接字发送消息)时,现在都会发布新的事件。
TcpConnectionEventListeningMessageProducer 已弃用。
请改用通用事件适配器。
有关更多信息,请参阅TCP 连接事件。
@InboundChannelAdapter变更
以前,入站通道适配器的 @Poller 默认将 maxMessagesPerPoll 属性设置为 -1(无穷大)。
这与 <inbound-channel-adapter/> 的 XML 配置不一致,后者默认为 1。
现在注解将该属性默认值设置为 1。
API 变更
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.
Reactor 仍然受支持,用于诸如 Promise 网关等功能。
对于不需要该功能的用户,已移除了相关依赖项。
JMS 变更
本节介绍 Spring Integration TCP 功能的一般变更。
回复监听器延迟初始化
您现在可以在 JMS 出站网关中将回复监听器的配置设置为按需初始化,并在空闲期后停止,而不是由网关的生命周期控制。 有关更多信息,请参见 出站网关。
默认确认模式
当使用隐式定义的 DefaultMessageListenerContainer 时,默认的 acknowledge 现在为 transacted。
我们建议在使用此容器时使用 transacted,以避免消息丢失。
此默认设置现在适用于消息驱动的入站适配器(inbound adapter)和入站网关(inbound gateway)。
对于基于 JMS 的通道,它早已是默认值。
共享订阅
我们已为消息驱动端点和<int-jms:publish-subscribe-channel>添加了共享订阅(JMS 2.0)的命名空间支持。
此前,若要使用共享连接,必须将监听器容器配置为<bean/>声明。
有关更多信息,请查看 JMS 支持。
AMQP 变更
本节介绍 Spring Integration AMQP 功能的一般变更。
发布者确认
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>).
关联数据
对于出站通道适配器和入站网关,如果关联数据为 Message<?>,它将作为确认或否定确认通道上消息的基础,并附加额外的头部信息。
此前,任何关联数据(包括 Message<?>)都会作为确认或否定确认消息的有效负载返回。
入站网关属性
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 支持。
XPath 拆分器改进
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.
有关更多信息,请参阅 拆分 XML 消息。
HTTP 变更
本节描述了 Spring Integration HTTP 功能的一般变更。
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).
有关更多信息,请参见 跨域资源共享 (CORS) 支持。
入站网关超时
您可以配置 HTTP 入站网关,使其在请求超时时返回您指定的状态码。
默认值现在是 500 Internal Server Error,而不是 200 OK。
有关更多信息,请参阅 响应状态码。
表单数据
我们已添加关于代理 multipart/form-data 请求的文档。
有关更多信息,请参阅 HTTP 支持。
网关变更
本节描述了对 Spring Integration Gateway 功能的通用更改。
[[gateway-methods-can-return-completablefuture<?>]]
==== Gateway 方法可以返回 CompletableFuture<?>
使用 Java 8 时,网关方法现在可以返回 CompletableFuture<?>。
更多信息请参见 CompletableFuture。
MessagingGateway 注解
请求和响应超时属性现在为 String 而不是 Long,以允许使用属性占位符或 SpEL 进行配置。
请参阅 @MessagingGateway 注解。
聚合器变更
本节介绍 Spring Integration 聚合器功能的一般变更。
聚合器性能
本次发布包含一些针对聚合组件(包括聚合器、重排序器等)的性能改进,通过更高效地在消息释放时将其从组中移除来实现。
已在消息存储中添加了新方法 (removeMessagesFromGroup)。
设置 removeBatchSize 属性(默认值:100)可调整每次操作删除的消息数量。
目前,JDBC、Redis 和 MongoDB 消息存储支持此属性。
输出消息组处理器
当为聚合器使用 ref 或内部 Bean 时,现在可以直接绑定 MessageGroupProcessor。
此外,我们添加了一个 SimpleMessageGroupProcessor,用于返回组中的消息集合。
当输出处理器产生 Message<?> 的集合时,聚合器会逐个释放这些消息。
配置 SimpleMessageGroupProcessor 可使聚合器成为消息屏障,消息将被暂存直到全部到达,随后再逐个释放。
有关更多信息,请参阅 聚合器。
FTP 和 SFTP 变更
本节描述了 Spring Integration FTP 和 SFTP 功能的通用变更。
入站通道适配器
您现在可以在入站通道适配器上指定 remote-directory-expression,以在运行时确定目录。
有关更多信息,请参阅 FTP/FTPS 适配器 和 SFTP 适配器。
默认 Sftp 会话工厂
此前,DefaultSftpSessionFactory无条件允许连接到未知主机。
现在此行为可配置(默认值:false)。
工厂现在需要一个已配置的 knownHosts,除非 allowUnknownKeys 属性为 true(默认值:false),否则必须提供文件。
消息会话回调
我们在 <int-(s)ftp:outbound-gateway/> 中介绍了如何使用 requestMessage 上下文执行任何自定义 Session 操作,并引入了 MessageSessionCallback<F, T>。
有关更多信息,请参阅使用MessageSessionCallback和MessageSessionCallback。
WebSocket 变更
我们向 WebSocketHandlerDecoratorFactory 添加了 ServerWebSocketContainer 支持,以便为内部 WebSocketHandler 实现链式自定义。
有关更多信息,请参阅 WebSockets 命名空间支持。
应用程序事件适配器更改
The ApplicationEvent 适配器现在可以像 payload 作为 event 一样工作,从而直接允许省略自定义的 ApplicationEvent 扩展。
为此,我们在 <int-event:outbound-channel-adapter> 上引入了名为 publish-payload 的布尔属性。
有关更多信息,请参阅 Spring ApplicationEvent 支持。