Aleksandra5kova / FruitbasketDemoEJB

0 stars 0 forks source link

Create EJB timers in Clustered Glassfish environment #2

Open matebate opened 7 years ago

matebate commented 7 years ago

Two (or more) timers should be created in the application. These EJB timers should be non-persistent. Because this is a clustered environment that you already created yourself, the goal is the following:

  1. Only one timer should 'fire up' and be executed (at the moment it creates file) per cluster. A mechanism should be implemented to synchronize the timers across the cluster.

There are multiple ways of achieving this (JMS,shared DB ...).

You should use the approach with the shared DB. The nodes of the cluster have a shared DB that will act as a control point of execution.

A table should be created for the synchronization purpose.

Aleksandra5kova commented 7 years ago

I've created a table which contains a column with unique constraint. When singleton object is created, it tries to insert record in the timer table and to create an EJB timer. So, when exception will occur, because of the unique constraint, EJB timer isn't created.