title: Multiple instances of a Quarts job to emulate timer functionality
body: <p>I have a Grails application and need to set a timer, something that will initiate a broadcast via WebSocket at a given time, with the following stipulations:  </p>
  
  <ul>
  <li>A timer can be postponed or cancelled  </li>
  <li>There might be several different timers running at the same time (but with different "contexts")  </li>
  <li>Clustered mode should be supported, i.e. a timer fires only once regardless of the number of instances of my app in a cluster.</li>
  </ul>
  
  <p>The solution I have come up with is:  </p>
  
  <ul>
  <li>Use Quartz to create an ordinary job without any given date for when it should be fired  </li>
  <li>The moment I want to set a timer, I create a new instance of the job with a <strong>cronExpression</strong> to fire it at a given time, and then save it persistently  </li>
  <li>Should I need to postpone the timer, I fetch it from the DB and rewrite the <strong>cronExpression</strong> to a new value instead.</li>
  </ul>
  
  <p>My concerns are:  </p>
  
  <ol>
  <li>Is there any other way I can "set a timer" in Grails, possibly without using the concept of Quartz jobs?  </li>
  <li>It is <a href="http://www.intelligrape.com/blog/2010/06/14/running-multiple-instances-of-a-quartz-job-dynamically/" rel="nofollow">possible to have multiple instances of a Quartz job</a>, but is it the right way to use Quartz, or should it be avoided? Maybe I should use <a href="http://grails-plugins.github.io/grails-quartz/guide/triggers.html" rel="nofollow">custom triggers</a> instead?  </li>
  <li>If I go the way I explained before, is it going to work in a clustered mode (multiple instances)?</li>
  </ol>