如何解决Spring Integration-入站通道适配器,用于执行下游通道并行处理
我正在尝试在以下工作流程中全部配置注释
带有轮询器(定时触发器)的入站通道适配器计划每30分钟运行一次 轮询文件表单目录(即10个文件)并移至舞台目录 对于每个文件,需要并行调用一个批处理作业,即10个作业应与所轮询的不同文件并行运行
我能够完成所有任务,但无法配置下游执行程序通道以并行运行作业。
下面是参考实现。 Eveyrything正在运行,即在文件之后启动作业,但是需要并行启动不同文件的作业 感谢对此的任何帮助
@InboundChannelAdapter (incoming channel,custompoller)
public MessageSource<File> pollFile ( Directory Scanner) {
}
public PollerMetadata custompoller(errorhandler) {
poller.trigger(cron for every 10 minutes)
}
@ServiceActivator(incoming channel)
public MessageHandler filewritertotempdiretory() {
outputchannel(tempdirchannel)
}
@ServiceActivator(inputChannel = tempdirchannel)
public MessageHandler tempdirfilehandler() {
MethodInvokingMessageHandler messageHandler = (launcher class,"methodname");
return messageHandler;
}
Poller Metadata. Read in some other SO that we should not put the task executor when setting poller on cron,is that true ?
also how can i make the messages polled (say 10 messages polled) execute in parallel i.e. add task executor in poller metadata
@Bean
public PollerMetadata preProcessPoller(MessagePublishingErrorHandler errorHandler) {
PollerMetadata poller = new PollerMetadata();
poller.setTrigger(new CronTrigger("0/15 * * * * ?"));
poller.setMaxMessagesPerPoll(Long.valueOf(maxMessagesPerPoll));
errorHandler.setDefaultErrorChannel(errorChannel());
poller.setErrorHandler(errorHandler);
return poller;
}
解决方法
您需要显示完整的PollerMetadata
配置。
最好的猜测是您尚未设置maxMessagesPerPoll
。
默认情况下,对于入站通道适配器,maxMessagesPerPoll
为1。
您可以将TaskExecutor
添加到轮询器元数据以并行运行消息,或将incoming channel
设为ExecutorChannel
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。