Timer service in the Ejb container

Discussions

EJB design: Timer service in the Ejb container

  1. Timer service in the Ejb container (7 messages)

    Hi everybody
    Is there any smart and as far as possible portable solution to have a timer service in a EJB container ( I am considering a possible solution to be implemented in an EJB container compliant to j2EE 1.3 ; I am looking forward to the J2EE 1.4 supporting timer services)
    thanks a lot in advance for your help
    claudio.

    Threaded Messages (7)

  2. In J2EE 1.3, the best way to manage timer services is outside the EJB container. For example, you could start a timer thread in the init() method of a servlet with load-on-startup="true", and put this servlet in the same EAR as your EJBs.

    If you really want the service to run inside the EJB container, I suggest you launch it from a Message-Driven Bean, and invoke this bean as part of startup process for your server.
  3. In J2EE 1.3, the best way to manage timer services is outside the EJB container. For example, you could start a timer thread in the init() method of a servlet with load-on-startup="true", and put this servlet in the same EAR as your EJBs.

    >
    > If you really want the service to run inside the EJB container, I suggest you launch it from a Message-Driven Bean, and invoke this bean as part of startup process for your server.

    Paul thanks very much for your answer
    I well understand the first approach in the servlet context but I am a bit confused on the second approach you are suggesting for the ejb container
    The question is --> which message (and who is the agent triggering this message)
    wake up the message driven bean? ( you are referring to a sturtup process but is it a portable approach?)
  4. I well understand the first approach in the servlet context but I am a bit

    > confused on the second approach you are suggesting for the ejb container
    > The question is --> which message (and who is the agent triggering this message)
    > wake up the message driven bean? ( you are referring to a sturtup process but
    > is it a portable approach?)

    The server startup scripter will have to invoke the message bean. Alternately, you can write a separate process that invokes the message bean every time you restart the server. The message bean will be portable, but the startup script will not be. The startup script should be very simple, though.

    I would go with the servlet-based approach myself, since it is 100% portable.
  5. Timer in EJB 2.0[ Go to top ]

    You could use the timer server in JMX, which is provided
    in many app servers such as WebLogic.

    I have used theses classes:

    import weblogic.management.timer.Timer;

    import javax.management.NotificationListener;
    import javax.management.Notification;
    import javax.management.InstanceNotFoundException;

    You could download the standard JMX and load it into your EJB container.

    Daoqi Yang
  6. Timer in EJB 2.0[ Go to top ]

    Hi , i'm must use a Timer service (as you suggested)
    to check new mail on a pop3 folder and save some information on DB.

    To save on DB i call a ejb session stateless ; but doesn't work.

    Do you know why ??? Weblogic tell to me : "i can't find the name of your EJB"....
  7. One of the big design issues with a timer service in J2EE is getting it to work when you run multiple application servers in production. Sure there is no issue if wish the job the service is kicking off to run on every application server (JMX timer works well) but it does get more complex if you wish the job you are kicking off only to run once and handle failover if the application server fails.

    For these jobs we wrote an external timer application java application that will kick of the job at the defined time. It will detect failure and will retry the job on a different a application server if failure is detected.

    David
  8. Timer service in the Ejb container[ Go to top ]

    I want to create a schedular.Say I will say my schedular after 1 hour it has to do job no1 and say after 2 hours it has to do job 2.And at the same time i want to persist that schedules so that if server goes down it should not loose my schedules.I am using weblogic 8.1.Can anyone help me
    Thanks
    Sougata