我的要求是我想在固定的时间间隔后停止轮询器,比如 9(小时)。现在我试图在 1 分钟后停止轮询。以下是我的代码:
<int-task:scheduler id="scheduler" pool-size="10"/>
<int-task:scheduled-tasks scheduler="scheduler">
<int-task:scheduled ref="incomingFiles.adapter" method="stop" fixed-delay="#{10 * 1000}"/>
</int-task:scheduled-tasks>
但现在我观察到的是,当我启动我的程序然后在启动时,我立即在控制台中收到以下消息:
> INFO: Starting beans in phase 0 May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started incomingFiles.adapter May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding {service-activator} as a
> subscriber to the 'incomingFiles' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext@f4d5bc9.incomingFiles'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started
> org.springframework.integration.config.ConsumerEndpointFactoryBean#0
> May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding {router} as a subscriber to
> the 'contextStartedEventChannelChannel' channel May 28, 2014 10:27:55
> AM org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext@f4d5bc9.contextStartedEventChannelChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started
> org.springframework.integration.config.ConsumerEndpointFactoryBean#1
> May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding
> {outbound-channel-adapter:trueChannel.adapter} as a subscriber to the
> 'trueChannel' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext@f4d5bc9.trueChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started trueChannel.adapter May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding
> {outbound-channel-adapter:falseChannel.adapter} as a subscriber to the
> 'falseChannel' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext@f4d5bc9.falseChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started falseChannel.adapter May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding
> {logging-channel-adapter:_org.springframework.integration.errorLogger}
> as a subscriber to the 'errorChannel' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext@f4d5bc9.errorChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started _org.springframework.integration.errorLogger May 28, 2014
> 10:27:55 AM
> org.springframework.integration.file.FileReadingMessageSource receive
> INFO: Created message: [[Payload File
> content=C:\TEMP\incomingFile\ETD.CONFIRM.60326.140519.T0613170][Headers={id=b003893a-e013-57c8-0c96-55db627ec643, timestamp=1401287275402}]] May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint stop INFO:
> stopped incomingFiles.adapter
在启动日志开头的某个地方,我们得到:
2014 年 5 月 28 日上午 10:27:55 org.springframework.integration.endpoint.AbstractE ndpoint 开始信息:开始传入文件.适配器
在启动日志末尾的某处,我们得到:
2014 年 5 月 28 日上午 10:27:55 org.springframework.integration.endpoint.AbstractE ndpoint 停止信息:停止传入文件.适配器
为什么在我们的 fixed-delay="#{10 * 1000}" 为 10 秒时,incomingFiles.adapter 立即停止。时间完全一样,绝对没有延迟。所以理想情况下轮询器应该在 10 秒后停止。而不是立即。目录中还有4个文件,它只拾取一个。
请建议有什么问题。