Skip to content

Commit

Permalink
Update sample-parent-context following changes to integration starter
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Apr 18, 2016
1 parent a2489b0 commit b9d7a39
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
4 changes: 4 additions & 0 deletions spring-boot-samples/spring-boot-sample-parent-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-file</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jmx</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,71 @@

package sample.parent;

import java.io.File;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec;
import org.springframework.integration.dsl.core.Pollers;
import org.springframework.integration.dsl.support.Consumer;
import org.springframework.integration.file.FileReadingMessageSource;
import org.springframework.integration.file.FileWritingMessageHandler;

@SpringBootApplication
@EnableConfigurationProperties(ServiceProperties.class)
public class SampleParentContextApplication {

@EnableAutoConfiguration
@ImportResource("integration-context.xml")
protected static class Parent {

@Bean
public FileReadingMessageSource fileReader() {
FileReadingMessageSource reader = new FileReadingMessageSource();
reader.setDirectory(new File("target/input"));
return reader;
}

@Bean
public DirectChannel inputChannel() {
return new DirectChannel();
}

@Bean
public DirectChannel outputChannel() {
return new DirectChannel();
}

@Bean
public FileWritingMessageHandler fileWriter() {
FileWritingMessageHandler writer = new FileWritingMessageHandler(
new File("target/output"));
writer.setExpectReply(false);
return writer;
}

@Bean
public IntegrationFlow integrationFlow(SampleEndpoint endpoint) {
return IntegrationFlows.from(fileReader(), new FixedRatePoller())
.channel(inputChannel()).handle(endpoint).channel(outputChannel())
.handle(fileWriter()).get();
}

private static class FixedRatePoller
implements Consumer<SourcePollingChannelAdapterSpec> {

@Override
public void accept(SourcePollingChannelAdapterSpec spec) {
spec.poller(Pollers.fixedRate(500));
}

}

}

public static void main(String[] args) throws Exception {
Expand Down

This file was deleted.

0 comments on commit b9d7a39

Please sign in to comment.