Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Spring集成的文件轮询_Spring_File_Integration_Using_Polling - Fatal编程技术网

使用Spring集成的文件轮询

使用Spring集成的文件轮询,spring,file,integration,using,polling,Spring,File,Integration,Using,Polling,如何使用SpringIntegrationAPI轮询特定文件目录中的多个文件,而不使用xml配置,最好使用基于Java注释的方法? 我想得到轮询文件列表,并对它们进行迭代,然后进一步处理。这是要求。任何样品 可用于满足此要求的代码。提前谢谢。下面是我使用的代码片段 @Bean @InboundChannelAdapter(value = "fileInputChannel", poller = @Poller(fixedDelay = "60000",maxMessage

如何使用SpringIntegrationAPI轮询特定文件目录中的多个文件,而不使用xml配置,最好使用基于Java注释的方法? 我想得到轮询文件列表,并对它们进行迭代,然后进一步处理。这是要求。任何样品 可用于满足此要求的代码。提前谢谢。下面是我使用的代码片段

    @Bean    
    @InboundChannelAdapter(value = "fileInputChannel", poller = @Poller(fixedDelay = "60000",maxMessagesPerPoll="5"))     
public MessageSource<File> fileReadingMessageSource() {    
    txtSource = new FileReadingMessageSource();   
    txtSource.setDirectory(inputDir);   
    txtSource.setFilter(new SimplePatternFileListFilter("*.txt"));  
    txtSource.setScanEachPoll(true);  
        return txtSource;  
}  
     @Bean     
     @Transformer(inputChannel = "fileInputChannel", outputChannel = "processFileChannel")  
        public FileToStringTransformer fileToStringTransformer() {  
            Message<File> message1 = txtSource.receive();  
            File file1 = message1.getPayload();  
            return new FileToStringTransformer();  
        }    
@Bean
@InboundChannelAdapter(value=“fileInputChannel”,poller=@poller(fixedDelay=“60000”,maxMessagesPerPoll=“5”))
public MessageSource fileReadingMessageSource(){
txtSource=新文件读取消息源();
setDirectory(inputDir);
setFilter(新的SimplePatternFileListFilter(“*.txt”);
txtSource.setScanEachPoll(true);
返回txtSource;
}  
@豆子
@转换器(inputChannel=“fileInputChannel”,outputChannel=“processFileChannel”)
公共文件ToString Transformer文件ToString Transformer(){
message1=txtSource.receive();
文件file1=message1.getPayload();
返回新文件toString Transformer();
}    

但是,不管输入目录中没有文件,消息源实例总是只获取一个文件。不确定如何使其适用于多个要获取的文件。

您可以尝试将
任务执行器添加到实现中

Follow post可同时轮询多个文件,但它不遵循基于注释的方法。和post进行文件的顺序轮询。这还涉及到注释的使用。

您可以尝试将任务执行器添加到实现中 Follow post可同时轮询多个文件,但它不遵循基于注释的方法。和post进行文件的顺序轮询。这也涉及到注释的使用