/** * Factory for the {@link FileInboundChannelAdapterSpec} * @param directory the based directory to poll * @param receptionOrderComparator the {@link Comparator} to order the files * in the internal queue * @return the FileInboundChannelAdapterSpec instance */ public FileInboundChannelAdapterSpec file(File directory, Comparator<File> receptionOrderComparator) { return Files.inboundAdapter(directory, receptionOrderComparator); }
/** * Factory for the {@link FileInboundChannelAdapterSpec} * @param directory the based directory to poll * @param receptionOrderComparator the {@link Comparator} to order the files * in the internal queue * @return the FileInboundChannelAdapterSpec instance */ public FileInboundChannelAdapterSpec file(File directory, Comparator<File> receptionOrderComparator) { return Files.inboundAdapter(directory, receptionOrderComparator); }
public static FileInboundChannelAdapterSpec inboundAdapter(File directory) { return inboundAdapter(directory, null); }
public static FileInboundChannelAdapterSpec inboundAdapter(File directory) { return inboundAdapter(directory, null); }
@Bean public IntegrationFlow fileToFile() { return IntegrationFlows.from(Files.inboundAdapter(new File("/tmp/in")) .autoCreateDirectory(true) .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000))) .transform(Transformers.fileToString()) .transform("payload.replaceAll('\r\n', '\n')") .handle(Files.outboundAdapter("'/tmp/out'") .autoCreateDirectory(true)) .get(); }
@Bean public IntegrationFlow fileToFile() { return IntegrationFlows.from(Files.inboundAdapter(new File("/tmp/in")) .autoCreateDirectory(true) .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000))) .transform(Transformers.fileToString()) .transform("payload.replaceAll('\r\n', '\n')") .publishSubscribeChannel(c -> c .subscribe(s -> s.handle(Files.outboundAdapter("'/tmp/out'") .autoCreateDirectory(true))) .subscribe(s -> s.log(LoggingHandler.Level.WARN, null, "headers['file_originalFile'].absolutePath + ' transferred'"))) .get(); }
@Bean public IntegrationFlow fileSplitterAggregator() { return IntegrationFlows .from(Files.inboundAdapter(new File("/tmp/in")) .autoCreateDirectory(true) .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000))) .split(Files.splitter() .markers() .applySequence(true)) .filter(p -> !(p instanceof FileSplitter.FileMarker), e -> e.discardChannel("aggregatorChannel")) .<String, Name>transform(Name::new) .<Name>filter(p -> !p.getValue().startsWith("X")) .channel("aggregatorChannel") .aggregate(a -> a.processor(new FileMarkerAggregator())) .<List<Name>, Names>transform(Names::new) .transform(Transformers.marshaller(jaxbMarshaller(), new ResultToStringTransformer())) .handle(Files.outboundAdapter("'/tmp/out'") .fileNameGenerator(m -> m .getHeaders() .get(FileHeaders.FILENAME, String.class) .replace(".txt", ".xml")) .autoCreateDirectory(true)) .get(); }