Pollers
Spring 集成还提供 fluent API,用于配置 AbstractPollingEndpoint
实现的 PollerMetadata
。可使用 Pollers
构建器工厂配置通用 Bean 定义或从 IntegrationFlowBuilder
EIP 方法创建的 Bean 定义,如下例所示:
Spring Integration also provides a fluent API that lets you configure PollerMetadata
for AbstractPollingEndpoint
implementations.
You can use the Pollers
builder factory to configure common bean definitions or those created from IntegrationFlowBuilder
EIP methods, as the following example shows:
@Bean(name = PollerMetadata.DEFAULT_POLLER)
public PollerSpec poller() {
return Pollers.fixedRate(500)
.errorChannel("myErrors");
}
更多信息,请参见 Javadoc 中的 link:https://docs.spring.io/spring-integration/api/org/springframework/integration/dsl/Pollers.html[Pollers
和 link:https://docs.spring.io/spring-integration/api/org/springframework/integration/dsl/PollerSpec.html[PollerSpec
。
See Pollers
and PollerSpec
in the Javadoc for more information.
如果你使用 DSL 将 PollerSpec
构建为 @Bean
,则不要在 Bean 定义中调用 getObject()
方法。PollerSpec
是 FactoryBean
,从规范生成 PollerMetadata
对象并初始化其所有属性。
If you use the DSL to construct a PollerSpec
as a @Bean
, do not call the getObject()
method in the bean definition.
The PollerSpec
is a FactoryBean
that generates the PollerMetadata
object from the specification and initializes all of its properties.