Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I coordinate a single ejb timer deployed to multiple servers within my WebLogic cluster?

So, I have a web client and an EJB timer, deployed seperately.

The workflow is as follows:

1) User accesses client. 2) User requests an action to take place which is known to be long-running, so we write the request to run this process in a database table. 3) TimerOne is checking this table every few seconds to see if there are any waiting tasks, so it finds the user's request and runs the task.

My problem is that in some environments in which our application is run, we are taking advantage of server clustering. When we do this, both the client and the EJB timer are deployed to each server in the cluster.

It is okay for the client to be deployed to multiple servers, as it helps with workload; however, having the timer run on multiple servers is an issue. When the user requests for a long-running task to be run, both timers grab the task at the same time from the database and start running it. As the long-running jobs usually write to the database, this scenario leads to collisions, among other issues.

My goal is to be able to deploy my EJB timer to both servers, but for there to be some state maintained across the cluster which can be used by the timers to decide whether they should pick up the task or if one of the other instances has already picked it up.

I tried using the database for this and tried file storage, but these are either too slow, or I could not come up with a bullet-proof workflow for synchronization.

Does anyone know of a good way to handle this problem? Is it even possible?

The solution should be able to run on a clustered WebLogic domain, a non-clustered WebLogic domain, a clustered Glassfish domain, and a non-clustered Glassfish domain.

I am open to changing the way this is done, if there is another, more elegent solution.

Thanks for any ideas!

like image 539
sager Avatar asked Jan 29 '14 20:01

sager


1 Answers

Yes this is possible with clustered timers or a Weblogic Singleton Service (and has been asked a number of times here already). See the following:

Clustered timers:

https://blogs.oracle.com/muraliveligeti/entry/ejb_timer_ejb

http://shaoxiongyang.blogspot.com/2010/10/how-to-use-ejb-3-timer-in-weblogic-10.html

http://java.sys-con.com/node/43944

Singleton Services:

https://blogs.oracle.com/jamesbayer/entry/a_simple_job_scheduler_example

http://developsimpler.blogspot.com/2012/03/weblogic-clusters-and-singleton-service.html

like image 103
Display Name is missing Avatar answered Oct 31 '22 17:10

Display Name is missing