i have following code in ftp inb channel adptr, company telling me i'm logging in every second...
public static void main(string[] args) { springapplication.run(ftpinboundapp.class, args); } @bean public sessionfactory<ftpfile> ftpsessionfactory() { defaultftpsessionfactory sf = new defaultftpsessionfactory(); sf.sethost(remotehost); sf.setport(remoteport); sf.setusername(remoteuser); sf.setpassword(remotepassword); return sf; } @bean @serviceactivator(inputchannel = "data", advicechain = "after") public messagehandler handler() { return new messagehandler() { @override public void handlemessage(message<?> message) throws messagingexception { try { httpposthgfiles.gethgfilesfromrestful(message.getpayload().tostring()); httppost990.get990fromrestful(message.getpayload().tostring()); } catch (ioexception e) { logger.error(e); } catch (exception e) { logger.error(e); } } }; } @bean public expressionevaluatingrequesthandleradvice after() { expressionevaluatingrequesthandleradvice advice = new expressionevaluatingrequesthandleradvice(); advice.setonsuccessexpression("@template.remove(headers['file_remotedirectory'] + headers['file_remotefile'])"); advice.setpropagateevaluationfailures(true); return advice; } @bean @inboundchanneladapter(value = "stream", poller = @poller(fixedrate = "1000")) public messagesource<inputstream> ftpmessagesource() { ftpstreamingmessagesource messagesource = new ftpstreamingmessagesource(template(), null); messagesource.setremotedirectory(remotedirectory); messagesource.setfilter(filter()); return messagesource; } public filelistfilter<ftpfile> filter() { compositefilelistfilter<ftpfile> filter = new compositefilelistfilter<>(); filter.addfilter(new ftpsimplepatternfilelistfilter("xxxx_aaa204*")); filter.addfilter(acceptoncefilter()); return filter; } @bean public ftppersistentacceptoncefilelistfilter acceptoncefilter() { ftppersistentacceptoncefilelistfilter filter = new ftppersistentacceptoncefilelistfilter(meta(), "xxxx_aaa204"); filter.setflushonupdate(true); return filter; } @bean public concurrentmetadatastore meta() { propertiespersistingmetadatastore meta = new propertiespersistingmetadatastore(); meta.setbasedirectory("/tmp/foo"); meta.setfilename("ftpstream.properties"); return meta; } @bean @transformer(inputchannel = "stream", outputchannel = "data") public org.springframework.integration.transformer.transformer transformer() { return new streamtransformer("utf-8"); } @bean public ftpremotefiletemplate template() { return new ftpremotefiletemplate(ftpsessionfactory()); } @bean(name = pollermetadata.default_poller) public pollermetadata defaultpoller() { pollermetadata pollermetadata = new pollermetadata(); pollermetadata.settrigger(new periodictrigger(600_000)); return pollermetadata; }
why? cause have:
@inboundchanneladapter(value = "stream", poller = @poller(fixedrate = "1000
??? in understanding setting:
pollermetadata.settrigger(new periodictrigger(300_000));
would make me log every 5 min?
and fixedrate = "1000
make me take next file every second...
since use fixedrate
there, don't use pollermetadata.default_poller
, there fore connect ftp each second.
the @poller
, pollermetadata.default_poller
represents same entity , mutually exclusive.
the logging ftp , file downloading happened @ same session. so, no difference target ftp server.
Comments
Post a Comment