org.springframework.integration.dsl.file.Files Java Examples
The following examples show how to use
org.springframework.integration.dsl.file.Files.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationConfiguration.java From messaging with Apache License 2.0 | 6 votes |
@Bean IntegrationFlow etlFlow( @Value("${input-directory:${HOME}/Desktop/in}") File dir) { return IntegrationFlows // <1> .from(Files.inboundAdapter(dir).autoCreateDirectory(true), consumer -> consumer.poller(spec -> spec.fixedRate(1000))) // <2> .handle(File.class, (file, headers) -> { log.info("we noticed a new file, " + file); return file; }) // <3> .routeToRecipients( spec -> spec.recipient(csv(), msg -> hasExt(msg.getPayload(), ".csv")) .recipient(txt(), msg -> hasExt(msg.getPayload(), ".txt"))).get(); }
Example #2
Source File: EtlFlowConfiguration.java From messaging with Apache License 2.0 | 5 votes |
@Bean IntegrationFlow etlFlow( @Value("${input-directory:${HOME}/Desktop/in}") File directory, BatchChannels c, JobLauncher launcher, Job job) { return IntegrationFlows .from(Files.inboundAdapter(directory).autoCreateDirectory(true), cs -> cs.poller(p -> p.fixedRate(1000))) .handle( File.class, (file, headers) -> { String absolutePath = file.getAbsolutePath(); // <2> JobParameters params = new JobParametersBuilder().addString("file", absolutePath).toJobParameters(); return MessageBuilder.withPayload(new JobLaunchRequest(job, params)) .setHeader(ORIGINAL_FILE, absolutePath) .copyHeadersIfAbsent(headers).build(); }) // <3> .handle(new JobLaunchingGateway(launcher)) // <4> .routeToRecipients( spec -> spec.recipient(c.invalid(), this::notFinished).recipient( c.completed(), this::finished)).get(); }
Example #3
Source File: FileSourceConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Bean public IntegrationFlow fileSourceFlow() { FileInboundChannelAdapterSpec messageSourceSpec = Files.inboundAdapter(new File(this.properties.getDirectory())); if (StringUtils.hasText(this.properties.getFilenamePattern())) { messageSourceSpec.patternFilter(this.properties.getFilenamePattern()); } else if (this.properties.getFilenameRegex() != null) { messageSourceSpec.regexFilter(this.properties.getFilenameRegex().pattern()); } if (this.properties.isPreventDuplicates()) { messageSourceSpec.preventDuplicates(); } IntegrationFlowBuilder flowBuilder = IntegrationFlows .from(messageSourceSpec, new Consumer<SourcePollingChannelAdapterSpec>() { @Override public void accept(SourcePollingChannelAdapterSpec sourcePollingChannelAdapterSpec) { sourcePollingChannelAdapterSpec .poller(defaultPoller); } }); return FileUtils.enhanceFlowForReadingMode(flowBuilder, this.fileConsumerProperties) .channel(source.output()) .get(); }
Example #4
Source File: IntegrationConfiguration.java From building-microservices with Apache License 2.0 | 5 votes |
@Bean IntegrationFlow incomingFiles(@Value("${HOME}/Desktop/in") File dir) { return IntegrationFlows.from( Files.inboundAdapter(dir) .preventDuplicates() .autoCreateDirectory(true), poller -> poller.poller(spec -> spec.fixedRate(1, TimeUnit.SECONDS))) .channel( this.files()) .get(); }