
Questions: 23,661 //
Answers: 52,175 //
Contributing Members: 17,932
We have an application which runs on CloudHub. There is a flow which has to be started at specific time of the day, so we used Quartz message processor for that with configured cron expression matching our needs. Our application on CloudHub is currently configured only with 1 worker and everything works fine.
We are planning to go to 2-3 workers instead of 1 in the near future.
The problem is in case of multiple workers the flow is started on each worker which leads to data corruption, as we are calling some external systems to create some objects and the data are duplicated.
Is there some reasonable way how to restrict the scheduled flow execution only on 1 worker ? I've read that Poll Scope should help in clustered environment but that is probably something different than CloudHub workers, isn't it.
I was thinking to use ObjectStore for storing some timestamp on each execution of scheduled flow and comparing that to current timestamp to make a decision to continue the flow (in case it is first execution) or to stop (in case it was already executed once).
Nov 15, 2017 at 03:55 PM, kevinj answered with:
Hi Peter,
The Poll scope is your friend. It will ensure that the job is started on only one worker if the application is deployed to multiple workers. For CloudHub it behaves as described here: https://docs.mulesoft.com/runtime-manager/managing-schedules
Bear in mind this will not prevent the case where if the job is executed on one worker and it takes an abnormally long time to execute and therefore doesn't finish before the next job is scheduled.
Also, I'm intrigued. Given the predisposition with only having the job execute on a single worker, what is the rationale behind scaling the application across multiple workers? How will the application actually be able to take advantage of the additional horizontal scalability?
With kind regards
Kevin
Thank you, I've already tried Poll scope and it's working fine. For your last question, scheduled job is only minor part of our application and we still want to go to multi-worker setup later on to split the load.
Nov 09, 2017 at 12:21 PM, sairahassan answered with:
Use Poll scope instead of quartz connector. As per Mulesoft Documetnation When running in an environment with multiple workers and nodes, a Quartz scheduler, by default, runs on each node whereas the Poll Scope is "smart" enough to only run on a single node. A Quartz scheduler can be configured to work the same as the Poll Scope, but requires configuration of a JDBC JobStore https://docs.mulesoft.com/mule-user-guide/v/3.6/quartz-connector