Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest 使用耗时HTTP请求接近调度器的设计_Rest_Http_Mule_Scheduled Tasks_Mulesoft - Fatal编程技术网

Rest 使用耗时HTTP请求接近调度器的设计

Rest 使用耗时HTTP请求接近调度器的设计,rest,http,mule,scheduled-tasks,mulesoft,Rest,Http,Mule,Scheduled Tasks,Mulesoft,我需要设计一个流,它应该每3分钟触发一次调度程序,它将触发一个HTTP请求。HTTP请求是一个耗时的操作,比如说它必须获取/写入大约15-50MB的文件。当请求仍在处理时,我不希望调度器再次触发请求。 使用Mulesoft设计此流的最佳方法是什么 我可以想到的一个解决方案是用异步作用域包装HTTP。但它仍然允许调度程序触发下一个请求 <async doc:name="Async"> <!-- One or more processors here --> </a

我需要设计一个流,它应该每3分钟触发一次调度程序,它将触发一个HTTP请求。HTTP请求是一个耗时的操作,比如说它必须获取/写入大约15-50MB的文件。当请求仍在处理时,我不希望调度器再次触发请求。 使用Mulesoft设计此流的最佳方法是什么

我可以想到的一个解决方案是用异步作用域包装HTTP。但它仍然允许调度程序触发下一个请求

<async doc:name="Async">
  <!-- One or more processors here -->
</async>

可以通过将调度流的最大并发性设置为1来实现这一点,这意味着不允许并行执行流

mule 4中的一个简化示例尝试每秒触发一次,但流程需要5秒才能完成。只处理第五个事件

<flow name="sandboxFlow" maxConcurrency="1">
    <scheduler doc:name="Scheduler">
        <scheduling-strategy >
            <fixed-frequency />
        </scheduling-strategy>
    </scheduler>
    <logger level="INFO" doc:name="Log Start" message="Start"/>
    <scripting:execute doc:name="Sleep" engine="groovy">
        <scripting:code >sleep(5000);</scripting:code>
    </scripting:execute>
    <logger level="INFO" doc:name="Log End" message="Finish"/>
</flow>
这样做的一个问题是,每当调度程序在流处理前一个作业时触发时,您都会收到一条错误消息,这看起来有点令人讨厌

********************************************************************************
Message               : Flow 'sandboxFlow' is unable to accept new events at this time
Error type            : MULE:FLOW_BACK_PRESSURE
Element               : sandboxFlow @ sandbox:sandbox.xml:22
Element XML           : <flow name="sandboxFlow" doc:id="a01c0292-b993-437b-976f-92903703fbae" maxConcurrency="1">
...
如果要避免日志中的错误消息,而日志属性中没有一揽子规则,可以使用队列并将其分成两个流

<flow name="sandboxFlow">
    <scheduler doc:name="Scheduler">
        <scheduling-strategy >
            <fixed-frequency frequency="2000"/>
        </scheduling-strategy>
    </scheduler>
    <vm:publish queueName="controlQ" doc:name="Publish" config-ref="VM_Config"/>
</flow>
<flow name="sandboxFlow2" maxConcurrency="1">
    <vm:listener doc:name="Listener" config-ref="VM_Config" numberOfConsumers="1" queueName="controlQ"/>
    <logger level="INFO" doc:name="Log Start" message="Start" />
    <scripting:execute doc:name="Execute" engine="groovy">
        <scripting:code >sleep(5000);</scripting:code>
    </scripting:execute>
    <logger level="INFO" doc:name="Log End" message="Finish" />
</flow>
第一个流按照计划运行,每次触发时,它只是将触发器放在队列上并完成

读取队列的流是单线程的,因此每次只运行一个,并且当队列上有触发消息时。这实现了相同的行为,但日志中没有错误消息

希望这有帮助