carcaret
carcaret

Reputation: 3358

EJB 3.0 TimerService redeploy

A few weeks ago we developed an EJB 3.0 TimerService to schedule some tasks on demand (when the user clicked a button, we would create the timer to perform some tasks). So far it's been working well, until today.

Yesterday we redeployed the EJB containing de TimerService to update some properties, and today no timers were fired, even though there were some created.

¿Is this normal? I mean, if you don't change the signature of the ejbTimeOut, shouldn't it launch as always after a redeploy?

Upvotes: 0

Views: 817

Answers (4)

Ráfagan
Ráfagan

Reputation: 2255

Use asadmin redeploy command with --keepstate flag equals to true.

Full example:

asadmin redeploy --keepstate=true --name=taskee-1.0-SNAPSHOT target/taskee-1.0-SNAPSHOT.war

More info in:

http://www.oracle.com/technetwork/articles/java/pongegf-1517943.html

Upvotes: 0

Doron Manor
Doron Manor

Reputation: 596

To make a timer persistent use the TimerHandle as explained here:

To save a Timer object for future reference, invoke its getHandle method and store the TimerHandle object in a database. (A TimerHandle object is serializable.) To re-instantiate the Timer object, retrieve the handle from the database and invoke getTimer on the handle. A TimerHandle object cannot be passed as an argument of a method defined in a remote or web service interface. In other words, remote clients and web service clients cannot access a bean’s TimerHandle object. Local clients, however, do not have this restriction.

Taken from http://docs.oracle.com/javaee/5/tutorial/doc/bnboy.html

Upvotes: 2

Lan
Lan

Reputation: 6660

That's the behavior in EJB 3.0. In EJB 3.1, timer service becomes much better. It supports automatic timer, which is created upon successful deployment. You may want to see if upgrading to EJB 3.1 is an option for you.

EE6 Tutorial: Using Timer Service

Enterprise bean timers are either programmatic timers or automatic timers. Programmatic timers are set by explicitly calling one of the timer creation methods of the TimerService interface. Automatic timers are created upon the successful deployment of an enterprise bean that contains a method annotated with the java.ejb.Schedule or java.ejb.Schedules annotations.

Upvotes: 0

Nayan Wadekar
Nayan Wadekar

Reputation: 11602

Timers are persistent by default. When you restart server, redeploy application etc. probably if they were missed out, will timeout.

I have faced similar issues in the past. Therefore it's advisable to cancel all previous existing timers & then create new one afterwards.

Upvotes: 1

Related Questions