spring如何同时读取和处理多个文件?

问题描述:

我是 Spring 框架的新手,我正在使用 spring 做一个简单的项目,但卡在了中间.在我的项目中,我正在使用 spring poller 从目录中读取文件.然后通过各种渠道处理该文件并将其发送到队列.但问题是文件入站通道适配器"(我正在使用)一次只读取一个文件.所以我需要一个可以一次读取和处理多个文件的解决方案.有没有办法在spring集成中实现多线程.谢谢.

I am new to Spring framework and I am doing one simple project using spring and got stuck in between. In my project I am reading the file from directory using spring poller. And then processing that file through various channels and sending it to the queue. But problem is that "file-inbound-channel-adapter" (which I'm using ) is reading only one file at a time. So I need a solution which will read and process multiple files at a time. Is there any way to implement multithreading in spring integration. Thank you.

向轮询器添加task-executor;请参阅文档.

Add a task-executor to the poller; see the documentation.

您可以使用 max-messages-per-poll 和任务执行器的池大小来控制并发.查看完整的轮询器配置细节 了解更多信息.

You can control the concurrency with max-messages-per-poll and the task executor's pool size. See the complete poller configuration details for more information.