3

I want to start mule quartz with condition.. For ex: In mule peroperties file I put one flag=on.If that flag is on then and only then Scheduler will be start.If that flag is off then schedule will be not called.

How can I do this in mule? Please help

user3855589
  • 1,113
  • 2
  • 15
  • 43

2 Answers2

0

Mule is wired up with Spring so the tricks/features you can use to make some beans conditional should work for Mule too.

I would try the following:

  • Extract the flow definition where the Quartz endpoint is started into quartz-config-on.xml
  • Create an empty Mule XML config named quartz-config-off.xml
  • In your main Mule XML config, use: <import resource="quartz-config-${quartz.flag}.xml"/> where quartz.flag is a property that is either on or off
Community
  • 1
  • 1
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Thanks for reply.but i can not directly import the resource.It give me error..How can I import resource?? – user3855589 Feb 11 '16 at 13:02
  • It really depends on how you defined your namespaces, but it can be something like this: https://github.com/ddossot/mule-in-action-2e/blob/f449bf36f5897d96ff0729f4536efabaa7509005/chapter09/src/test/resources/transaction/transaction-jdbc-single.xml#L12-L14 – David Dossot Feb 11 '16 at 15:51
0

I used a work around to achieve this kind of behavior. I defined a Quartz connector where the cron expression to trigger it is loaded from a property file.

If you put the expression to something that won't trigger until 2099 it's almost equivalent to a disabled cron.

<quartz:inbound-endpoint cronExpression="${cron1.expression}"
                jobName="scheduler1" doc:name="Scheduler 1">
    <quartz:event-generator-job>
        <quartz:payload>${cron1.request};${cron1.trade.date.offset}/quartz:payload>
    </quartz:event-generator-job>
</quartz:inbound-endpoint>

And the property file:

#Scheduler 1 settings
cron1.expression = 3 14 15 9 2 ? 2099
cron1.request = none
cron1.trade.date.offset = 0
Kristof W.
  • 43
  • 1
  • 7