Search code examples
spring-integrationspring-integration-dslfile-watcher

Spring IntegrationFlow for multi-tenancy application or multiple folders to watch


Is there a way to register IntegrationFlow for multi-tenancy. Assuming requirement is to process PF for few tenants such as INFY, TCS, WIPRO etc. Every tenant has it’s own directory path with the same pattern like /mount/batches/{tenantId}/pf.

Every tenant owns it's own folder as follows:

INFY –> /mount/batches/INFY/pf
TCS –> /mount/batches/TCS/pf
WIPRO –> /mount/batches/WIPRO/pf

InboundFlow accepting only one source directory and other answers in stackoverflow suggesting to have a separate InboundFlow definition for each folder, but we have almost 100 tenants to configure and for every new tenant we need to have code changes in such case.

Please suggest me, if there any way we can write an adaptor to watch multiple folders at once.


Solution

  • You can programmatically create multiple inbound adapters that send to the same channel.

    See the documeentation.

    With FTP/SFTP you can rotate between different servers and remote folders

    https://docs.spring.io/spring-integration/docs/5.3.0.RELEASE/reference/html/sftp.html#sftp-rotating-server-advice

    There is currently no equivalent for mounted folders.

    However, you could configure a custom DirectoryScanner that rotates between different folders by delegating to a list of scanners.