Update sample-parent-context following changes to integration starter
See gh-5528
This commit is contained in:
parent
a2489b01aa
commit
b9d7a39693
|
@ -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>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-file="http://www.springframework.org/schema/integration/file"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.3.xsd
|
||||
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-4.3.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<int-file:inbound-channel-adapter channel="input" directory="target/input" filename-pattern="*">
|
||||
<int:poller fixed-rate="500" />
|
||||
</int-file:inbound-channel-adapter>
|
||||
|
||||
<int:service-activator input-channel="input" ref="sampleEndpoint" output-channel="output"/>
|
||||
|
||||
<int:channel id="output"/>
|
||||
|
||||
<int-file:outbound-channel-adapter channel="output" directory="target/output"/>
|
||||
|
||||
</beans>
|
Loading…
Reference in New Issue