• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Quartz in multiple servers

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I'm trying to implement Quartz jobs in my web application, It's fine in development environment, because it's deployed only in one server, there are no load balancing, however the application, for production environment is deployed in 2 different servers, since my quartz jobs are meant to send e-mails every time they are executed, witout doing anything special, they would be sent twice, my first approach here is to add an special parameter to the servers, something like -DExecuteQuartz=Yes / No, being "Yes" for one server and "No" for the other one and, from my code, through the System.getProperty("ExecuteQuartz"), i would know whether this server will wxecute the quartz job or not, however, this would limit the quartz execution to just one server, what if this server is down by the time is scheduled to be executed, another approach would be the same, but scheduling the execution not once but at least twice a day, but then i would have to add an "Already Executed" status in the database or something...

Those are the only approaches i can think of, my question is, is there a better way to implement quartz jobs in multiple servers?

Thanks in advance for taking the time to answer this request...



Regards,
Julio Fernandez
 
Author
Posts: 3448
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly, it is not a best practice to run batch jobs inside a Web container. While it is perfectly legal, the quartz job can interfere with the container. It is better to run it as a separate stand alone process and you can cluster it if required. Check the Quartz documentation. For the cluster to work properly, you need to have the time on both servers synchronized via NTP. If clustering is not required, then deploy it to only one server.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic