Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-4478

EJB Timer implementation for GlobalSchedulerService

    XMLWordPrintable

Details

    • 0
    • 0% 0%

    Description

      EJB Timers have a few benefits to EE applications:

      • They support transactions out of the box
      • They support the @RequestScope scope
      • Server managed restarts out of the box

      For my particular use case, it is the Request scope that is crucial, as our application architecture relies on it in several places. When JBPM is being deployed in an EE environment, it would be very nice to have the option of using EJB timers instead of Quartz/Thread.

      I would envision using a stateless bean that activates a programmatic timer (http://docs.oracle.com/javaee/7/tutorial/doc/ejb-basicexamples004.htm).

      Here is a sample:

      @Stateless
      public class TestEjbTimer  {
      
      	 @Resource EJBContext context;
      
      	 public void start( Long objectId ) {
      		 
      		 TimerService service = context.getTimerService();
      		 service.createTimer(5000l, objectId);
      	 }
      
      	@Timeout
      	public void onTimeout( Timer timer ) {
                         Long objectId = (Long) timer.getInfo();
              }	        
      }
      

      Attachments

        Activity

          People

            swiderski.maciej Maciej Swiderski (Inactive)
            jblinick_jira Josh B (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: