Reputation: 233
I have setup file poller/channel adapter which polls a directory and handler integration flow using Java DSL. But I am not getting any reference how to add another directory/channel adapter and bridge to same handler. Here is my code.
@Bean
public IntegrationFlow integrationFlow(JobLaunchingGateway jobLaunchingGateway) {
return IntegrationFlows.from(Files.inboundAdapter(new File(incomingDir)).
filter(new SimplePatternFileListFilter("*.csv")).
filter(new AcceptOnceFileListFilter<>()),
c -> c.poller(Pollers.fixedRate(500).maxMessagesPerPoll(1))).
handle(fileMessageToJobRequest()).
handle(jobLaunchingGateway).
log(LoggingHandler.Level.WARN, "headers.id + ': ' + payload").
get();
}
Upvotes: 1
Views: 1402
Reputation: 233
Thanks @Artem. How about following ?
@Bean
public IntegrationFlow integrationFlowUi(JobLaunchingGateway jobLaunchingGateway) {
return IntegrationFlows.from(Files.inboundAdapter(new File(incomingDirUi)).
filter(new SimplePatternFileListFilter("*.csv")).
filter(new AcceptOnceFileListFilter<>()),
c -> c.poller(Pollers.fixedRate(500).maxMessagesPerPoll(1))).
channel("to-bridge").
handle(fileMessageToJobRequest()).
handle(jobLaunchingGateway).
log(LoggingHandler.Level.WARN, "headers.id + ': ' + payload").
get();
}
@Bean
public IntegrationFlow integrationFlowSftp(JobLaunchingGateway jobLaunchingGateway) {
return IntegrationFlows.from(Files.inboundAdapter(new File(incomingDirSftp)).
filter(new SimplePatternFileListFilter("*.csv")).
filter(new AcceptOnceFileListFilter<>()),
c -> c.poller(Pollers.fixedRate(500).maxMessagesPerPoll(1))).
channel("to-bridge").get();
}
Upvotes: 2
Reputation: 121177
One of the first class citizens in Spring Integration is a MessageChannel
entity. You always can set explicit channels between endpoints in you IntegrationFlow
definition and explicitly send messages to them.
For you “merging” use-case I would suggest to place a .channel()
before .handle()
and declare the second flow for the second directory, but in the end of that flow use the same .channel()
to “bridge” messages from this flow to the middle of the first one.
See more information in the reference manual : https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/html/java-dsl.html#java-dsl-channels
Upvotes: 1