我有一个入站文件通道适配器,其auto-startup属性设置为false。这个适配器是我的应用程序的起点;如果它不向系统发送通知文件的消息,我认为其他一切都是惰性的。
但是,在开始我的上下文时,消息开始流经系统。为什么?
配置:
<int-file:inbound-channel-adapter auto-startup="false" id="fileWatcher" directory="${input.dir}" channel="incomingFiles">
<int:poller fixed-rate="1000"></int:poller>
</int-file:inbound-channel-adapter>
<int:channel id="incomingFiles"></int:channel>Main方法:
public static void main(String[] args) {
logger.info("Started application");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:/spring-config/*.xml");
context.start();
}日志:
[...]
12:06:56.743 [main] INFO o.s.i.e.SourcePollingChannelAdapter - started fileWatcher
12:06:56.770 [task-scheduler-6] INFO o.s.i.file.FileReadingMessageSource - Created message: [[Payload=C:\input\From Spreadsheet.txt][Headers={timestamp=1343214416770, id=b8e92486-d469-406e-8787-df78e23b287a}]]发布于 2012-07-25 19:55:29
在适配器上设置auto-startup="false“(默认情况下为true )。
您可以手动启动它,获取对它的引用并调用fileWatcher.start()。如果包含集成MBean导出器,也可以通过JMX使用此功能。
或者,您可以向其有效负载中包含“@fileWatcher.start()”的发送消息。
哦;我刚注意到你已经有了。
不要调用context.start() -这将启动所有bean,而不管它们的自动启动设置。
自动启动控制,呃,自动启动-您正在手动启动上下文。
https://stackoverflow.com/questions/11648351
复制相似问题