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

EJB Timer implementation for GlobalSchedulerService

    Details

      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();
              }	        
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                swiderski.maciej Maciej Swiderski
                Reporter:
                jblinick Josh B
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: