Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a Scheduled Method in a Cluster for one Node and for All?

I have a Glassfish 3.1.2 that runs in a cluster and a EJB 3.1 application. And I need two kind of Scheduled Methods in my application:

  • one kind that runs only once (on a single node) once a day
  • and other kind that runs on all nodes (every 1-2 Minutes) -- They do NOT need to run a syncron way! The requirement is just that this kind run on every node.

I have no clue how to start with this cluster - problem, is this possible with @Schedule (and how) or do I need something else?

like image 378
Ralph Avatar asked Jun 28 '12 12:06

Ralph


1 Answers

I faced the exact same issue (need one cluster timer and a per node timer) and came across this question. So, for anyone interested:

If you declare the timer with @Schedule(..., persistent=true), you will get a cluster timer stored in the timer db (which can be migrated)

If you declare the timer with @Schedule(..., persistent=false), you will get a node timer not stored in the timer db (which can't be migrated)

like image 89
Tasos P. Avatar answered Oct 08 '22 05:10

Tasos P.