dev@glassfish.java.net

Re: trouble using EJBTimer in a cluster in Glassfish

From: Mahesh.Kannan <Mahesh.Kannan_at_Sun.COM>
Date: Wed, 14 Mar 2007 20:42:41 -0800

Can you send me the server.log(s) of the two instances with level set to
FINE? I'll try to reproduce this and let you know.
Thanks,
--Mahesh

Edward Chou wrote:

> Hi All,
>
> I am trying the following scenario in the latest Glassfish nightly
> build and its not working for me, any help is appreciated.
>
> 1) I created a cluster with 2 instances, and 1 nodeagent, called
> "instance-ONE", "instance-TWO", "cluster1-nodeagent", respectively
> 2) I have a simple Stateless EJB, and it is using TimerService to
> create a new Timer, see code below.
> 3) I then deployed this EJB to the cluster through admin-gui
> 4) I then invoke createTime() method through webservice on
> "instance-ONE", since I exposed my EJB as WS.
> 5) Now I am able to see the System.out.println() in the server.log of
> "instance-ONE" every 5 second, as expected.
> 6) Then I stop "instance-ONE" by invoking "asadmin stop-instance
> instance-ONE".
> 7) Now, I see the following log entries in "instance-TWO" server.log
>
> [#|2007-03-14T17:44:58.488-0700|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=25;_ThreadName=pool-2-thread-4;|
> Received Planned Shutdown Notification: instance-ONE|#]
>
> [#|2007-03-14T17:44:58.488-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=26;_ThreadName=pool-2-thread-5;|Got
> Planned Shutdown Notification[1]. shutdownNodeID: instance-ONE|#]
>
> [#|2007-03-14T17:44:58.488-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=26;_ThreadName=pool-2-thread-5;|Got
> Planned Shutdown Notification. shutdownNodeID: instance-ONE|#]
>
> [#|2007-03-14T17:44:58.488-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=26;_ThreadName=pool-2-thread-5;|Beginning
> timer migration process from owner instance-ONE to instance-TWO|#]
>
> [#|2007-03-14T17:44:58.638-0700|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=26;_ThreadName=pool-2-thread-5;|instance-ONE
> has 0 timers in need of migration|#]
>
> It complains about there is no timers to migrate from "instance-ONE"
> to "instance-TWO", but I do have a timer created in "instance-ONE".
> So my question is, am I doing it right or wrong? How do I use
> EJBTimer in a cluster environment?
>
> ***********************
> SessionBean code:
> ***********************
>
> @Stateless
> @WebService
> public class TimeSessionBean implements
> com.sun.test.TimeSessionLocal {
>
> @Resource
> TimerService timerService;
>
> /** Creates a new instance of TimeSessionBean */
> public TimeSessionBean() {
> }
>
> @WebMethod
> public void createTime(long initialDuration, long
> intervalDuration) {
> timerService.createTimer(initialDuration,
> intervalDuration, "testing timer");
> }
>
> @Timeout
> public void timeout(Timer timer) {
> System.out.println("timer timed out");
> }
> }
>
>
> Thanks
> Edward
>