PDA

View Full Version : Multiple FTPSources added dynamically



mdond
Jul 4th, 2008, 04:09 AM
Hello

I have the following scenario:

In a database I have FTP-Servers (about 60), which I want to use as FTP-Sources. On every FTP-Server 4 different file types should be polled and handled by the application. Additional FTP-Sources can be added while the application is running.

Are these to much FTP-Sources for spring integration?

Is it possible to add new FTP-Sources dynamically or have these to be configured before starting the application?

Is filtering by suffix possible in FTP-Sources? (It is possible in FileSources, but I can't see it in FTP-Sources).

Best regards,
Maarten Donders

mbogoevici
Jul 8th, 2008, 04:25 PM
Hi Maarten,

In principle you can have as many sources as you want.

For now, this kind of filtering is not possible, but you could retrieve all files with an FtpSource and then use a Router (or a MessageSelector) to send them to different handlers for processing. Of course, this currently has the major inconvenience that will still retrive *all* files, regardless whether the intent is to process them or not.

Please follow on http://jira.springframework.org/browse/INT-294 as we intend to improve the functionality in this respect.

Regards,
Marius

mdond
Jul 9th, 2008, 03:18 AM
Hi Marius,

Thank you for answering!

Is it possible to add (and remove) the FTPSources dynamically instead of by configuration?

I'll follow the jira request.

Regards,
Maarten

mdond
Jul 23rd, 2008, 02:40 AM
Just to answer my own question, it is straightforward. E.G. to register a file-source with 1.0M4:

MessageBus messageBus = (MessageBus) applicationContext.getBean(MessageBusParser.MESSAG E_BUS_BEAN_NAME);
FileSource fileSource = new FileSource(dir, messageCreator);
Schedule schedule = new PollingSchedule(pollingIntervalInMS);
MessageChannel channel = messageBus.lookupChannel(channelName);
SourceEndpoint fileSourceEndpoint = new SourceEndpoint(fileSource, channel, schedule);
messageBus.registerEndpoint(fileSourceId, fileSourceEndpoint);

Unregister:
messageBus.unregisterEndpoint(fileSourceId);

Regards,
Maarten