我有一个石英预定流程,只有在初始流程完成后才能运行。初始流程设置必须存在于文件中的数据,以使石英计划流程成功。但是,石英工艺开始,初始过程永远不会开始。我只希望初始化运行一次所以我不希望它在石英流程中运行。
<!-- 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>
有没有办法实现这个目标?我如何安排流程来实现我的目标?
答案 0 :(得分:1)
You can create two flows, one which will be triggered periodically but disabled on start-up and one that will set-up your data and activate the periodic flow. Something like:
<!-- 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>
Your initial flow will run once on start-up, but this "run a flow once" approach have some limits. If your application restart, the initial flow will run again - though this can be somehow mitigated by adding some logic to your initial flow.
答案 1 :(得分:0)
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>`
谢谢!