Mule file inbound connector with poll scope

1.5k views Asked by At

I'm trying to use mule inbound file connector with poll scope got error saying couldn't start endpoint. If I remove poll scope and use file connector with default polling and its working fine without any file path changes.

I was wondering why is Poll scope giving error? If file inbound connector not allowed to wrapped in poll scope, why anypoint studio showing poll scope in the wrap in option ?

I found similar question, but I didn't see detailed explanations.

Mule won't allow POLL message processor to read file using file Inbound?

Advance thanks for your response.

4

There are 4 answers

0
Deep On

you can create a file endpoint in the global element section and then use mule requester to invoke that endpoint inside a poll scope.

 <file:connector name="File1" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
    <file:endpoint connector-ref="File1" name="File" responseTimeout="10000" doc:name="File" path="/"/>
    <flow name="pocforloggingFlow1">
        <poll doc:name="Poll">
            <mulerequester:request resource="File" doc:name="Mule Requester"/>
        </poll>
    </flow>

1
Alex On

Please, provide SSCCE. Based on your question you do not need Poll at all. File Connector already has this feature to check file periodically. Here is example which polls file every 0.123 seconds

<file:inbound-endpoint path="/tmp" responseTimeout="10000" doc:name="File" pollingFrequency="123"/>
0
satya sandeep On

My suggestion is to use the quartz connector beside the file connector and set the interval in the quartz connector. Or use the file connector itself having the poll frequency so no need to wrap the file in poll scope.

0
Sanjeet Pandey On

Use mule-module-requester https://github.com/mulesoft/mule-module-requester, together with the Poll Scheduler.

relevant posts: http://blogs.mulesoft.com/dev/mule-dev/introducing-the-mule-requester-module/

Another way is,

Set the FTP flow initialState="stopped", and let the poll scheduler start the flow. After the FTP processing, stop the flow again.

see sample code:

<ftp:connector name="FTP" pollingFrequency="1000"
     validateConnections="true" moveToDirectory="/work/ftp/processed"
     doc:name="FTP" />
 <flow name="scheduleStartFTPFlow">
     <poll doc:name="Poll">
         <fixed-frequency-scheduler frequency="1"
             timeUnit="MINUTES" />
         <expression-component doc:name="START FTP FLOW"><![CDATA[if(app.registry.processFTPFlow.isStopped()){
            app.registry.processFTPFlow.start();
    }]]></expression-component>
     </poll>
     <logger message="Poll Logging: #[payload]" level="INFO"
         doc:name="Logger" />
 </flow>
 <flow name="processFTPFlow" initialState="stopped">
     <ftp:inbound-endpoint host="localhost" port="21"
         path="/data/ftp" user="Sanjeet" password="sanjeet123" responseTimeout="10000"
         doc:name="FTP" connector-ref="FTP" />
     <logger message="Logging FTP #[payload]" level="INFO" doc:name="Logger" />
     <expression-component doc:name="STOP FTP FLOW"><![CDATA[app.registry.processFTPFlow.stop();]]></expression-component>
 </flow>