Advertisement
Guest User

SI IntegrationFlowContext

a guest
Mar 12th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. @Autowired
  2.     private IntegrationFlowContext flowContext;
  3.  
  4. @PostConstruct
  5.     private void registerFilePollingFlows() {
  6.         configuration.getFiles().forEach(inboundSource -> {
  7.             IntegrationFlow flow = IntegrationFlows.from(s -> s.file(inboundSource.getReadFilePath())
  8.                             .preventDuplicates(true).scanEachPoll(true).patternFilter("*.txt"),
  9.                             e -> e.poller(Pollers.fixedDelay(inboundSource.getPollingPeriod())
  10.                                     .taskExecutor(taskExecutor())
  11.                                     .transactionSynchronizationFactory(transactionSynchronizationFactory(
  12.                                             inboundSource.getProcessedPath(), inboundSource.getFailedPath()))
  13.                                     .transactional(transactionManager())))
  14.                     .log(LoggingHandler.Level.INFO, getClass().getName(), "'Read inbound file: ' .concat(payload)")
  15.                     .enrichHeaders(m -> {
  16.                         m.headerExpression(FileHeaders.ORIGINAL_FILE, "payload");
  17.                     })
  18.                     .transform(Transformers.fileToString())
  19.                     .channel(ApplicationConfiguration.FILE_INBOUND_CHANNEL)
  20.                     .get();
  21.             flowContext.registration(flow).autoStartup(true).register();
  22.         });
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement