spring integration - Dispatcher has no subscribers error for ftp -
i have file dropped @ ftp location should picked ftp-inbound-adapter. file saved local-directory. local-directory in turn polled spring file-inbound-adapter. filenamegenerator bean used in file-inbound-adapter , decides destination dynamically. have posted question file in local-directory not being deleted. problem facing. entire configuration
<util:properties id="someid" location="classpath:config/config.properties"/> <mvc:annotation-driven /> <context:component-scan base-package="com.dms" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <context:property-placeholder location="classpath:config/jdbc.properties,classpath:config/config.properties,classpath:config/ftp.properties"/> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource" > <property name="driverclassname" value="${jdbc.driverclassname}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource"> <ref bean="datasource" /> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop> </props> </property> <property name="packagestoscan"> <list> <value>com.dms.entity</value> </list> </property> </bean> <tx:annotation-driven /> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="multipartresolver" class="org.springframework.web.multipart.commons.commonsmultipartresolver"> <!-- setting maximum upload size --> <property name="maxuploadsize" value="10485760" /> </bean> <!-- scheduler pickup temp folder files permanent location --> <bean class="org.springframework.scheduling.quartz.schedulerfactorybean"> <property name="triggers"> <list> <ref bean="simpletrigger" /> </list> </property> </bean> <bean id="dmsfilesdetectionjob" class="com.dms.scheduler.job.dmsfilesdetectionjob"> </bean> <bean id="dmsfilesdetectionjobdetail" class="org.springframework.scheduling.quartz.methodinvokingjobdetailfactorybean"> <property name="targetobject" ref="dmsfilesdetectionjob" /> <property name="targetmethod" value="polltempfolder" /> <property name="concurrent" value="false" /> </bean> <bean id="simpletrigger" class="org.springframework.scheduling.quartz.crontriggerbean"> <property name="jobdetail" ref="dmsfilesdetectionjobdetail" /> <!-- <property name="cronexpression" value="1 * * * * ?" /> --> <property name="cronexpression" value="0 0/1 * * * ?" /> </bean> <bean id="filenamegenerator" class="com.dms.util.filenamegenerator"/> <int-file:inbound-channel-adapter id="filesin" directory="file:${paths.root}" channel="abc" filter="compositefilter" > <int:poller id="poller" fixed-delay="5000" /> </int-file:inbound-channel-adapter> <int:channel id="abc"/> <bean id="compositefilter" class="org.springframework.integration.file.filters.compositefilelistfilter"> <constructor-arg> <list> <!-- ensures file whole before processing --> <bean class="com.dms.util.customfilefilter"/> <!-- ensures files picked once directory --> <bean class="org.springframework.integration.file.filters.acceptoncefilelistfilter" /> </list> </constructor-arg> </bean> <int-file:outbound-channel-adapter channel="abc" id="filesout" directory-expression="@outpathbean.getpath()" delete-source-files="true" filename-generator="filenamegenerator" /> <bean class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"> <property name="messageconverters"> <list> <ref bean="jsonmessageconverter"/> </list> </property> </bean> <bean id="jsonmessageconverter" class="org.springframework.http.converter.json.mappingjackson2httpmessageconverter"> <!-- <property name="prefixjson" value="false"/> --> <!-- <property name="objectmapper"> <bean class="com.dms.util.hibernateawareobjectmapper" /> </property> --> <property name="supportedmediatypes" value="application/json"/> </bean> <bean id="ftpclientfactory" class="org.springframework.integration.ftp.session.defaultftpsessionfactory"> <property name="host" value="${ftp.ip}"/> <property name="port" value="${ftp.port}"/> <property name="username" value="${ftp.username}"/> <property name="password" value="${ftp.password}"/> <property name="clientmode" value="0"/> <property name="filetype" value="2"/> <property name="buffersize" value="100000"/> </bean> <int-ftp:outbound-channel-adapter id="ftpoutbound" channel="ftpchannel" session-factory="ftpclientfactory" charset="utf-8" remote-file-separator="/" auto-create-directory="true" remote-directory="." use-temporary-file-name="true" auto-startup="true" /> <int-ftp:inbound-channel-adapter id="ftpinbound" channel="ftpchannel" session-factory="ftpclientfactory" charset="utf-8" local-directory="file:${paths.root}" delete-remote-files="true" temporary-file-suffix=".writing" remote-directory="." filename-pattern="${file.char}*${file.char}" preserve-timestamp="true" auto-startup="true"> <int:poller fixed-rate="1000"/> </int-ftp:inbound-channel-adapter> <int:channel id="ftpchannel" />
this error getting
18:02:34.655 e|logginghandler |org.springframework.messaging.messagedeliveryexception: dispatcher has no subscribers channel 'org.springframework.web.context.webapplicationcontext:/dms/dms-dispatcher.ftpchannel'.
this exception not appear everytime. can see have added auto-startup="true". have used unique id's both channels adapters. please let me know wrong here!
thanks
i had deal file inbound-channel-adapter. issue intermittent, , @ startup. think adapters pollers can start pulling in messages before spring integration has initialized.
my fix disable adapter @ startup. details of adapter not important, other has id , set not autostart:
<!-- read files "inbox" directory, placing them on "inbox" channel... --> <int-file:inbound-channel-adapter id="inboxscanner" directory="$import{inbox}" auto-create-directory="true" channel="fileinbox" prevent-duplicates="false" auto-startup="false"> <int:poller fixed-rate="$import{inbox.scan.rate.seconds}" time-unit="seconds" max-messages-per-poll="$import{inbox.max.imports.per.scan}"/> </int-file:inbound-channel-adapter>
i tap spring's application lifecycle events, , once application context finished being created (or refreshed), tell adapter start:
<!-- start scanner after application has finished initializing... --> <int-event:inbound-channel-adapter event-types="org.springframework.context.event.contextrefreshedevent" channel="contextrefreshevents"/> <int:publish-subscribe-channel id="contextrefreshevents"/> <int:outbound-channel-adapter channel="contextrefreshevents" expression="@inboxscanner.start()" />
the "event" components spring-integration-event.
Comments
Post a Comment