[jboss-user] [JBoss Seam] - Quartz Asynchronous events at startup

Hypher do-not-reply at jboss.com
Wed Dec 5 17:51:06 EST 2007


I have been running into problems with Quartz Asynchronous events which are scheduled to fire when the server is shut down. When the server is started again, the events get fired before seam is fully initialized. This occurs because the QuartzDispatcher is marked @Startup and it will cause all post-dated events to be fired as soon as it is created. The component that is handing the asynchronous event relies on other components which are marked @Startup. Since startup order is arbitrary, some of those components won't have been created when the event is fired, causing errors.

The solution I have found to this issue is to override the QuartzDispatcher and wait until seam is initialized to initialize the scheduler:

  | @Startup
  | @Scope(ScopeType.APPLICATION)
  | @Name("org.jboss.seam.async.dispatcher")
  | @Install(value=false, precedence=APPLICATION)
  | @BypassInterceptors
  | public class CustomQuartzDispatcher extends QuartzDispatcher
  | {
  |     @Override
  |     public void initScheduler()
  |     {
  |         /* 
  |          * We don't actually want anything to happen on startup, 
  |          * this will be handled by the post-init startScheduler method
  |          */
  |     }
  | 
  |     @Observer("org.jboss.seam.postInitialization")
  |     public void startScheduler()
  |     {
  |         super.initScheduler();
  |     }
  | }
  | 

This approach works perfectly for events which were scheduled before the server went down, and for events scheduled after seam is initialized. However, if a seam component tries to schedule an event during startup, it will fail because the scheduler has not been initialized.

This could be fixed by keeping a queue of events to-be-scheduled in the QuartzDispatcher, and scheduling them with the scheduler once it is initialized.

Does anyone have any ideas about this? I'll create JIRA issue about the startup issue soon.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110688#4110688

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110688



More information about the jboss-user mailing list