Changes between 5.0 and 5.1
-
新增组件和集成支持,包括 java.util.function 接口、@LongRunningTest 注释和 AmqpDedicatedChannelAdvice。
-
针对调度程序异常、全局通道拦截器、ObjectToJsonTransformer 和集成流组件的 bean 名称进行了改进。
-
聚合器、文件支持、AMQP、JDBC、FTP、SFTP、TCP、Twitter、JMS、HTTP/WebFlux、JMX 和微表计支持方面进行了更改和增强。
-
集成图可以自定义,新的全局属性可以记录,并且 @Poller 注释具有一个接收超时选项。
New Components
以下组件在 5.1 中新增:
The following components are new in 5.1:
Improved Function Support
现在,java.util.function
接口在 Framework 组件中获得了改进的集成支持。Kotlin lambda 函数现在也可以用于处理程序和源方法。
The java.util.function
interfaces now have improved integration support in the Framework components.
Also Kotlin lambdas now can be used for handler and source methods.
@LongRunningTest
提供了一个 JUnit 5 @LongRunningTest
条件注释,用于检查环境或系统属性,其中 RUN_LONG_INTEGRATION_TESTS
条目的值为 true
,以确定是否运行或跳过测试。
A JUnit 5 @LongRunningTest
conditional annotation is provided to check the environment or system properties for the RUN_LONG_INTEGRATION_TESTS
entry with the value of true
to determine if test should be run or skipped.
General Changes
在 5.1 版本中进行了以下更改:
The following changes have been made in version 5.1:
Java DSL
IntegrationFlowContext
现在是一个接口,IntegrationFlowRegistration
是 IntegrationFlowContext
的内部接口。
The IntegrationFlowContext
is now an interface and IntegrationFlowRegistration
is an inner interface of IntegrationFlowContext
.
引入了新的 logAndReply()
运算符,以便在流的末尾针对请求-应答配置进行日志记录。这避免了与 log()
的混淆,log()
被视为单向末端流组件。
A new logAndReply()
operator has been introduced for convenience when you wish to log at the end of a flow for request-reply configurations.
This avoids confusion with log()
which is treated as a one-way end flow component.
针对集成流程中任何 NamedComponent
生成的 bean 名称现在基于组件类型,以便从视觉工具、日志分析器和指标收集器更好地读取。
A generated bean name for any NamedComponent
within an integration flow is now based on the component type for better readability from visual tools, logs analyzers and metrics collectors.
GenericHandler.handle()
现在会将 MessageHeaders
类型用作第二个参数。
The GenericHandler.handle()
now excepts a MessageHeaders
type for the second argument.
Dispatcher Exceptions
AbstractDispatcher
捕获并重新抛出的异常现在更一致:
Exceptions caught and re-thrown by AbstractDispatcher
are now more consistent:
-
A
MessagingException
of any kind that has afailedMessage
property is re-thrown unchanged. -
All other exceptions are wrapped in a
MessageDeliveryException
with thefailedMessage
property set.
以往:
Previously:
-
A
MessagingException
of any kind that has afailedMessage
property was re-thrown unchanged -
A
MessagingException
that had nofailedMessage
property was wrapped in aMessagingException
with thefailedMessage
property set. -
Other
RuntimeException
instances were re-thrown unchanged. -
Checked exceptions were wrapped in a
MessageDeliveryException
with thefailedMessage
property set.
Global Channel Interceptors
全局通道拦截器现在适用于动态注册的通道,例如,在使用 Java DSL 或使用 beanFactory.initializeBean()
初始化的 bean 时通过 IntegrationFlowContext
进行动态注册。以往,当应用程序上下文刷新后创建的 bean,不会应用拦截器。
Global channel interceptors now apply to dynamically registered channels, such as through the IntegrationFlowContext
when using the Java DSL or beans that are initialized using beanFactory.initializeBean()
.
Previously, when beans were created after the application context was refreshed, interceptors were not applied.
Channel Interceptors
当没有收到消息时,将不再调用 ChannelInterceptor.postReceive()
;不再需要检查 Message<?>
是否为 null
。以往会调用该方法。如果您有依赖于之前行为的拦截器,那么请实现 afterReceiveCompleted()
,因为该方法将被调用,无论是否收到消息。此外,PolledAmqpChannel
和 PolledJmsChannel
以前没有使用 null
调用 afterReceiveCompleted()
;现在会使用 null
进行调用。
ChannelInterceptor.postReceive()
is no longer called when no message is received; it is no longer necessary to check for a null
Message<?>
.
Previously, the method was called.
If you have an interceptor that relies on the previous behavior, implement afterReceiveCompleted()
instead, since that method is invoked, regardless of whether a message is received or not.
Furthermore, the PolledAmqpChannel
and PolledJmsChannel
previously did not invoke afterReceiveCompleted()
with null
; they now do.
ObjectToJsonTransformer
为 ObjectToJsonTransformer
引入了新的 ResultType.BYTES
模式。
A new ResultType.BYTES
mode is introduced for the ObjectToJsonTransformer
.
有关详细信息,请参阅 JSON Transformers。
See JSON Transformers for more information.
Integration Flows: Generated Bean Names
从版本 5.0.5 开始,集成流中组件的生成 bean 名称包括流 bean 名称,后跟一个句点,作为前缀。例如,如果流 bean 命名为 flowBean
,则生成的 bean 可能命名为 flowBean.generatedBean
。
Starting with version 5.0.5, generated bean names for the components in an IntegrationFlow
include the flow bean name, followed by a dot, as a prefix.
For example, if a flow bean were named flowBean
, a generated bean might be named flowBean.generatedBean
.
有关更多信息,请参见 Working With Message Flows。
See Working With Message Flows for more information.
Aggregator Changes
如果 groupTimeout
被计算为负值,则汇聚器现在立即使组失效。仅将 null
视为一个信号,即对当前消息不采取任何操作。
If the groupTimeout
is evaluated to a negative value, an aggregator now expires the group immediately.
Only null
is considered as a signal to do nothing for the current message.
已引入新的 popSequence
属性,以允许(默认情况下)为输出消息调用 MessageBuilder.popSequenceDetails()
。此外,为了进行优化,AbstractAggregatingMessageGroupProcessor
现在返回 AbstractIntegrationMessageBuilder
而不是整个 Message
。
A new popSequence
property has been introduced to allow (by default) to call a MessageBuilder.popSequenceDetails()
for the output message.
Also an AbstractAggregatingMessageGroupProcessor
returns now an AbstractIntegrationMessageBuilder
instead of the whole Message
for optimization.
有关详细信息,请参阅 Aggregator。
See Aggregator for more information.
@Publisher annotation changes
从版本 5.1 开始,您必须通过使用 @EnablePublisher
或通过在 <int:annotation-config>
上使用 <int:enable-publisher>
子元素来显式启用 @Publisher
AOP 功能。此外,已经添加 proxy-target-class
和 order
属性,以便调整 ProxyFactory
配置。
Starting with version 5.1, you must explicitly turn on the @Publisher
AOP functionality by using @EnablePublisher
or by using the <int:enable-publisher>
child element on <int:annotation-config>
.
Also the proxy-target-class
and order
attributes have been added for tuning the ProxyFactory
configuration.
See Annotation-driven Configuration with the @Publisher
Annotation for more information.
Files Changes
如果您正在使用 FileExistsMode.APPEND
或 FileExistsMode.APPEND_NO_FLUSH
,则可以提供一个 newFileCallback
,该回调在创建新文件时会调用。此回调会接收新创建的文件和触发回调的消息。例如,这可用于写入 CSV 标头。
If you are using FileExistsMode.APPEND
or FileExistsMode.APPEND_NO_FLUSH
you can provide a newFileCallback
that will be called when creating a new file.
This callback receives the newly created file and the message that triggered the callback.
This could be used to write a CSV header, for an example.
FileReadingMessageSource
现在只有在调用其 start()
之后才检查和创建目录。因此,如果 FileReadingMessageSource
的入站通道适配器具有 autoStartup = false
,则在应用程序启动期间不会出现针对文件系统的故障。
The FileReadingMessageSource
now doesn’t check and create a directory until its start()
is called.
So, if an Inbound Channel Adapter for the FileReadingMessageSource
has autoStartup = false
, there are no failures against the file system during application start up.
有关更多信息,请参见 File Support。
See File Support for more information.
AMQP Changes
我们已在 DefaultAmqpHeaderMapper
中对 ID
及 Timestamp
页眉映射进行了更改。有关更多信息,请参见 AMQP Message Headers 底部附近的注解。
We have made ID
and Timestamp
header mapping changes in the DefaultAmqpHeaderMapper
.
See the note near the bottom of AMQP Message Headers for more information.
contentType
标头现已正确映射为通用标头映射中的一个条目。有关更多信息,请参阅 contentType Header。
The contentType
header is now correctly mapped as an entry in the general headers map.
See contentType Header for more information.
从版本 5.1.3 起,如果在使用手动确认时发生消息转换异常,且已定义错误通道,则有效负载是一个 ManualAckListenerExecutionFailedException
,它包含附加的 channel
和 deliveryTag
属性。这使得错误流对原始消息进行确认/否定。有关更多信息,请参见 Inbound Message Conversion。
Starting with version 5.1.3, if a message conversion exception occurs when using manual acknowledgments, and an error channel is defined, the payload is a ManualAckListenerExecutionFailedException
with additional channel
and deliveryTag
properties.
This enables the error flow to ack/nack the original message.
See Inbound Message Conversion for more information.
JDBC Changes
JDBC 入站通道适配器和 JDBC 出站网关上的一个令人困惑的 max-rows-per-poll
属性已被弃用,转而使用新引入的 max-rows
属性。
A confusing max-rows-per-poll
property on the JDBC Inbound Channel Adapter and JDBC Outbound Gateway has been deprecated in favor of the newly introduced max-rows
property.
当请求消息的有效负载是 Iterable
类型的实例时,JdbcMessageHandler
现在支持 batchUpdate
功能。
The JdbcMessageHandler
supports now a batchUpdate
functionality when the payload of the request message is an instance of an Iterable
type.
(JdbcChannelMessageStore)
的 INT_CHANNEL_MESSAGE
表的索引已得到优化。如果您在该存储中有较大的消息组,则可能希望更改索引。
The indexes for the INT_CHANNEL_MESSAGE
table (for the JdbcChannelMessageStore
) have been optimized.
If you have large message groups in such a store, you may wish to alter the indexes.
有关更多信息,请参见 JDBC Support。
See JDBC Support for more information.
FTP and SFTP Changes
现在可以利用 RotatingServerAdvice
通过入站通道适配器轮询多个服务器和目录。有关更多信息,请参见 Inbound Channel Adapters: Polling Multiple Servers and Directories 和 Inbound Channel Adapters: Polling Multiple Servers and Directories。
A RotatingServerAdvice
is now available to poll multiple servers and directories with the inbound channel adapters.
See Inbound Channel Adapters: Polling Multiple Servers and Directories and Inbound Channel Adapters: Polling Multiple Servers and Directories for more information.
此外,入站适配器 localFilenameExpression
实例可包含 #remoteDirectory
变量,其中包含所轮询的远程目录。用于对流媒体适配器的获取文件列表进行排序的比较器的泛型类型已从 Comparator<AbstractFileInfo<F>>
更改为 Comparator<F>
。有关更多信息,请参见 FTP Streaming Inbound Channel Adapter 和 SFTP Streaming Inbound Channel Adapter。
Also, inbound adapter localFilenameExpression
instances can contain the #remoteDirectory
variable, which contains the remote directory being polled.
The generic type of the comparators (used to sort the fetched file list for the streaming adapters) has changed from Comparator<AbstractFileInfo<F>>
to Comparator<F>
.
See FTP Streaming Inbound Channel Adapter and SFTP Streaming Inbound Channel Adapter for more information.
此外,现在可以使用 Comparator
为入站通道适配器的同步器提供支持。当使用 maxFetchSize
限制检索的文件时,这一点非常有用。
In addition, the synchronizers for inbound channel adapters can now be provided with a Comparator
.
This is useful when using maxFetchSize
to limit the files retrieved.
CachingSessionFactory
有一个新属性 testSession
,当该属性为 true 时,工厂将在从缓存中签出现有会话时对 Session
执行 test()
操作。
The CachingSessionFactory
has a new property testSession
which, when true, causes the factory to perform a test()
operation on the Session
when checking out an existing session from the cache.
有关更多信息,请参见 SFTP Session Caching 和 FTP Session Caching。
See SFTP Session Caching and FTP Session Caching for more information.
出站网关 MPUT 命令现在支持带有文件或字符串集合的消息有效负载。有关更多信息,请参见 SFTP Outbound Gateway 和 FTP Outbound Gateway。
The outbound gateway MPUT command now supports a message payload with a collection of files or strings. See SFTP Outbound Gateway and FTP Outbound Gateway for more information.
TCP Support
在使用 SSL 时,现在默认情况下启用主机验证,以防止对拥有受信任证书的人在中间进行攻击。有关更多信息,请参阅 Host Verification。
When using SSL, host verification is now enabled, by default, to prevent man-in-the-middle attacks with a trusted certificate. See Host Verification for more information.
此外,现在可以在 DefaultTcpSSLContextSupport
上配置密钥和信任库类型。
In addition the key and trust store types can now be configured on the DefaultTcpSSLContextSupport
.
Twitter Support
由于 Spring Social 项目已迁移到 end of life status,Twitter 在 Spring Integration 中的支持已迁移到 Extensions 项目。有关更多信息,请参阅 Spring Integration Social Twitter。
Since the Spring Social project has moved to end of life status, Twitter support in Spring Integration has been moved to the Extensions project. See Spring Integration Social Twitter for more information.
JMS Support
JmsSendingMessageHandler
现在提供 deliveryModeExpression
和 timeToLiveExpression
选项,以确定在运行时要发送的 JMS 消息的相应 QoS 选项。DefaultJmsHeaderMapper
现在允许通过将 setMapInboundDeliveryMode()
和 setMapInboundExpiration()
选项设置为 true
,来映射入站 JMSDeliveryMode
和 JMSExpiration
属性。当停止 JmsMessageDrivenEndpoint
或 JmsInboundGateway
时,现在会关闭关联的侦听器容器;这会关闭其共享连接和任何使用者。您可以配置这些终结点以恢复到之前的行为。
The JmsSendingMessageHandler
now provides deliveryModeExpression
and timeToLiveExpression
options to determine respective QoS options for JMS message to send at runtime.
The DefaultJmsHeaderMapper
now allows to map inbound JMSDeliveryMode
and JMSExpiration
properties via setting to true
respective setMapInboundDeliveryMode()
and setMapInboundExpiration()
options.
When a JmsMessageDrivenEndpoint
or JmsInboundGateway
is stopped, the associated listener container is now shut down; this closes its shared connection and any consumers.
You can configure the endpoints to revert to the previous behavior.
有关更多信息,请参见 JMS Support。
See JMS Support for more information.
HTTP/WebFlux Support
statusCodeExpression
(和 函数
)现在随 RequestEntity<?>
(用作求值上下文的根对象)一起提供,以便请求标头、方法、URI 和正文可用于目标状态代码计算。
The statusCodeExpression
(and Function
) is now supplied with the RequestEntity<?>
as a root object for evaluation context, so request headers, method, URI and body are available for target status code calculation.
有关更多信息,请参见 HTTP Support 和 WebFlux Support。
See HTTP Support and WebFlux Support for more information.
JMX Changes
如果对象名称键值包含 Java 标识符(或句点 .
)中不允许的任何字符,则现在会将其引用。例如 org.springframework.integration:type=MessageChannel,
name="input:foo.myGroup.errors"
。这会产生副作用,即之前包含此类字符的“允许”名称现在会变成引用。例如 org.springframework.integration:type=MessageChannel,
name="input#foo.myGroup.errors"
。
Object name key values are now quoted if they contain any characters other than those allowed in a Java identifier (or period .
).
For example org.springframework.integration:type=MessageChannel,
name="input:foo.myGroup.errors"
.
This has the side effect that previously "allowed" names, with such characters, will now be quoted.
For example org.springframework.integration:type=MessageChannel,
name="input#foo.myGroup.errors"
.
Micrometer Support Changes
现在,自定义框架创建的标准 Micrometer 仪表更容易了。有关更多信息,请参阅 Micrometer Integration。
It is now simpler to customize the standard Micrometer meters created by the framework. See Micrometer Integration for more information.
Integration Graph Customization
现在可以通过 IntegrationGraphServer
上的 Function<NamedComponent, Map<String, Object>> additionalPropertiesCallback
,将其他属性添加到 IntegrationNode
中。有关详细信息,请参阅 Integration Graph。
It is now possible to add additional properties to the IntegrationNode
s via Function<NamedComponent, Map<String, Object>> additionalPropertiesCallback
on the IntegrationGraphServer
.
See Integration Graph for more information.
Integration Global Properties
现在可以在日志中打印集成全局属性(包括默认值),前提是已针对 org.springframework.integration
类别开启 DEBUG
逻辑级别。有关更多信息,请参见 Global Properties。
The Integration global properties (including defaults) can now be printed in the logs, when a DEBUG
logic level is turned on for the org.springframework.integration
category.
See Global Properties for more information.
The receiveTimeout
for @Poller
现在,{@Poller
} 注解提供了一个方便的 {receiveTimeout
} 选项。有关更多信息,请参见 {Using the @Poller
Annotation}。
The @Poller
annotation now provides a receiveTimeout
option for convenience.
See Using the @Poller
Annotation for more information.