EJB 3 clustered timers (thorntail 2.2.0)

125 views
Skip to first unread message

markus.s

unread,
Sep 19, 2018, 9:42:01 AM9/19/18
to Thorntail
Hello,

has anyone successfully used the java ee timer function in a clustered setup ?

With the following configuration I had no success.
Tried it on one machine with 2 thorntail instances and one database but timers are triggered on every instance.
Maybe someone has a hint for me:

swarm:
  ejb3
:
    timer
-service:
     
default-data-store: clustered-store
      thread
-pool-name: default
      database
-data-stores:
        clustered
-store:
          database
: oracle
          datasource
-jndi-name: java:jboss/datasources/my_ds
          partition
: timer
          refresh
-interval: 60000
  datasources
:
    data
-sources:
     
my_ds:
        user
-name: my_ds
        driver
-name: oracle
        initial
-pool-size: 3
       
. . .

-------------------

@Singleton
@Startup
public class ScheduleSample {

   
@Resource
   
private TimerService timerService;

   
@Schedule(hour = "*", minute = "*", second = "*/40", info = "Every second timer", persistent = true)
   
public void printDate() {
       
System.out.println("### <It is " + LocalDateTime.now() + "> ###");
   
}

}

KR
Markus

john-als

unread,
Sep 24, 2018, 8:48:16 AM9/24/18
to Thorntail
seems to work for me, how do the content in the database looks? 
TABLE, jboss_ejb_timer ? 

markus.s

unread,
Sep 24, 2018, 9:21:58 AM9/24/18
to Thorntail
Yes, it is jboss_ejb_timer table.

On startup of each of both instances a new entry is created by thorntail in that table. Probably that is the root cause... not sure.

96fa7f01-4da1-4bb8-9167-332380a3c371,52403b5d-a508-4ffc-88e9-1b950ddb1476.52403b5d-a508-4ffc-88e9-1b950ddb1476.ScheduleSample,,0,24.09.2018 15:16:00,000000,24.09.2018 15:15:40,018000,,ACTIVE,*/40,*,*,*,*,*,*,,,,1,printDate,ScheduleSample,,1,timer,

130b7849-bf20-4d09-8014-cd848dba7dfa,9f268875-2cf5-4945-88b8-2a447442800b.9f268875-2cf5-4945-88b8-2a447442800b.ScheduleSample,,0,24.09.2018 15:16:00,000000,24.09.2018 15:15:40,018000,,ACTIVE,*/40,*,*,*,*,*,*,,,,1,printDate,ScheduleSample,,1,timer,

john-als

unread,
Sep 24, 2018, 9:37:53 AM9/24/18
to Thorntail
yeah the timed_object_id seems generated for each node? how are you running it? this is mine

c124bdc9-de45-47c9-be72-7afb9e6f4313 timer-1.0.0-SNAPSHOT.timer-1.0.0-SNAPSHOT.TimerService (null) 0 2018-09-24 15:36:00 2018-09-24 15:35:50 (null) BD4SRXZlcnkgc2Vjb25kIHRpbWVy ACTIVE */10 * * * * * * (null) (null) (null) true se.cluster.TimerService printDate true timer (null)

markus.s

unread,
Sep 24, 2018, 9:40:22 AM9/24/18
to Thorntail
what do you mean by "how are you running it?"

markus.s

unread,
Sep 24, 2018, 9:48:36 AM9/24/18
to Thorntail
ok, my fault. running it as a standalone process via IDE is not a good idea.
thorntail generates a UUID war file name
thanks ...

john-als

unread,
Sep 24, 2018, 9:53:25 AM9/24/18
to Thorntail
Great! =) 

markus.s

unread,
Sep 24, 2018, 10:14:16 AM9/24/18
to Thorntail
Nevertheless, you have to be careful with deployments.
Normally you choose a new version number with a new deployment which can cause trouble on multiple servers.
So for a short while it is possible having multiple timers being active...

john-als

unread,
Sep 24, 2018, 10:27:51 AM9/24/18
to Thorntail
Use final name in maven so it's have same file name depending on versions, not perfect but it works. Should be nice to configure the name

john-als

unread,
Sep 24, 2018, 10:28:08 AM9/24/18
to Thorntail
Reply all
Reply to author
Forward
0 new messages