骡子流不触发

Mule flow is not triggering

我在 Poll 中使用 Groovy 来检查给定位置的文件是否存在。 当有文件时,我的流程工作正常。但是如果我删除那个文件,流程就不是 triggering.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. 我无法确定 运行 我的流程的确切解决方案。我必须处理这种情况,给定的文件不存在。

除了 null 之外,您还需要 return 轮询器目标中的其他内容才能调用流。我建议在子流程中执行此操作:

<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>