Update sample-parent-context following changes to integration starter
See gh-5528
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user