骡子流不会触发

问题描述 投票:0回答:1

我在Poll中使用Groovy来检查给定位置的文件是否存在。当有文件时,我的流程正常。但如果我删除该文件,则流不会触发.Below是我的代码

<flow name="monitor-dst-file-flow">
    <poll doc:name="Poll">
        <schedulers:cron-scheduler expression="0 0 23 ? * TUE-SAT"/>
        <scripting:transformer doc:name="Groovy">
            <scripting:script engine="Groovy"><![CDATA[def endpointBuilder = muleContext.endpointFactory.getEndpointBuilder( 
                "sftp://${user}:${pwForGroovy}@${host}:${port}${inputpath}/?connector=SFTP")                    
                endpointBuilder.addMessageProcessor(new org.mule.routing.MessageFilter(new org.mule.transport.file.filters.FilenameWildcardFilter('test.txt'))) 

def inboundEndpoint = endpointBuilder.buildInboundEndpoint()inboundEndpoint.request(30000L)]]>

        </scripting:transformer>
    </poll>
    <choice doc:name="Choice">
        <when expression="#[message.inboundProperties.originalFilename ==&quot;test.txt&quot;]">
            <logger level="INFO" doc:name="Logger" message="File Exists..."/>
        </when>
        <otherwise>

            <logger message="FILE EXISTS" level="ERROR" doc:name="Logger"/>

            <flow-ref name="email-notification-sub-flow" doc:name="Flow Reference"/>

        </otherwise>
    </choice>
</flow>

在这里,如果没有test.txt文件,我无法调试Choice组件。

它说-Polling of monitor-dst-file-flow returned null, the flow will not be invoked.我无法确定运行流量的确切解决方案。我必须处理那个条件,给定的文件不在那里。

mule mule-component mule-el mule-esb
1个回答
1
投票

您需要从轮询器的目标返回除null之外的内容,以便调用流。我建议在子流程中这样做:

<flow name="monitor-dst-file-flow">
  <poll doc:name="Poll">
    <schedulers:cron-scheduler expression="0 0 23 ? * TUE-SAT"/>
    <flow-ref name="pollerProcessor" doc:name="pollerProcessor"/>
  </poll>
  <choice doc:name="Choice">
    <when expression="#[payload == 'file not found']">
      <logger level="INFO" doc:name="Logger" message="File Exists..."/>
    </when>
    <otherwise>
      <logger message="FILE EXISTS" level="ERROR" doc:name="Logger"/>
      <flow-ref name="email-notification-sub-flow" doc:name="Flow Reference"/>
    </otherwise>
  </choice>
</flow>
<sub-flow name="pollerProcessor">
  <scripting:transformer doc:name="Groovy">
    <scripting:script engine="Groovy"><![CDATA[def endpointBuilder = muleContext.endpointFactory.getEndpointBuilder( 
      "sftp://${user}:${pwForGroovy}@${host}:${port}${inputpath}/?connector=SFTP")                    
      endpointBuilder.addMessageProcessor(new org.mule.routing.MessageFilter(new org.mule.transport.file.filters.FilenameWildcardFilter('test.txt'))) 
      def inboundEndpoint = endpointBuilder.buildInboundEndpoint() inboundEndpoint.request(30000L)]]>
    </scripting:script>
  </scripting:transformer>
  <set-payload value="#[payload == null ? 'file not found' : payload]" doc:name="Set Payload"/>
</sub-flow>
© www.soinside.com 2019 - 2024. All rights reserved.