Mule - 如何安排在 Quartz 计划流程之前仅 运行 一次的流程

Mule - How to arrange a flow which should only run once before a Quartz scheduled flow

我有一个 quartz 计划流,它应该只在初始流完成后 运行。初始流程设置数据,这些数据必须存在于文件中才能使 quartz 计划进程成功。但是,石英进程启动,而初始进程从未启动。我只希望首字母 运行 一次,所以我不希望它在石英流中成为 运行。

     <!-- Needs to run only once -->
      <flow name="InitialJob">
       <component ....
     </flow>

    <!-- Depends on InitialJob -->
    <flow name="ScheduledProcess">
          <quartz:inbound-endpoint responseTimeout="10000" doc:name="Schd" 
            cronExpression="0 */5 * * * ?" jobName="doIt" 
            repeatInterval="0">
            <quartz:event-generator-job/>
         </quartz:inbound-endpoint>

         <!-- I don't want to put InitialJob  here, 
           I only want it to run once
              -->
        <flow-ref name="PerformJob"/>
   </flow>

有办法实现吗?我如何安排流程来实现我的目标?

In your initial flow try to start the quartz flow like this`<expression-component>
    app.registry.yourflowName.start();
  </expression-component>`

Then in after quartz flow is finished try to stop the initial flow with below script:`<expression-component>
    app.registry.yourflowName.stop();
  </expression-component>`

谢谢!

您可以创建两个流,一个将定期触发但在启动时禁用,另一个将设置您的数据并激活周期性流。类似于:

    <!-- Will run periodically once started -->
    <flow name="PeriodicJob" initialState="stopped">
        <quartz:inbound-endpoint jobName="PeriodicJob" cronExpression="* * * * * ?" repeatInterval="0" responseTimeout="10000" doc:name="Quartz">
            <quartz:event-generator-job/>
        </quartz:inbound-endpoint>
        <flow-ref name="PerformJob"/>
    </flow>

    <!-- Will run once on start-up and activate PeriodJob -->
    <flow name="InitialJobRunOnce">
        <quartz:inbound-endpoint jobName="InitialJobRunOnce" repeatInterval="0" repeatCount="0" startDelay="0" responseTimeout="10000" doc:name="Quartz">
            <quartz:event-generator-job/>
        </quartz:inbound-endpoint>
        <expression-component doc:name="Activate period job"><![CDATA[app.registry.PeriodicJob.start();]]></expression-component>
    </flow>

您的初始流程将 运行 启动一次,但这种 "run a flow once" 方法有一些限制。如果您的应用程序重新启动,初始流程将再次 运行 - 尽管可以通过向初始流程添加一些逻辑来以某种方式缓解这种情况。