views:

912

answers:

5

Hello everyone.

I want to be able to :

  • define different jobs and triggers.
  • modify the expirations dates and intervals on demand
  • pause or cancel an execution (trigger)

the jobs would be ejbs or call ejbs and i would want to manage everything from the website (the user will have to define the executions)

So i looked at the timerservice, timerobjects, timer and timerhandle. But i think it can't answer to all my needs

Quartz, on the other hand, allows me to do every thing that i want, but i haven't the slightest clue on how to integrate this into my jboss. I read that quartz uses its own threadpool, and i don't know how to handle all this.

I use Jboss Seam in my project, but the seam/quartz integration is very limited (or the documentation is) and not 100% safe (seen on their forum : 'run forever' tasks end after only a few weeks)

If someone managed to integrate a good scheduler into his application server (jboss is a plus) and could give me directions, advices, or even code snippets, i would be thrilled.

Thanks in advance.

+1  A: 

I have some experience integrating Quartz into a Weblogic (no jboss experience, sorry) application server. Quartz has a built in listener class that will be called upon server startup (per J2EE specs) that automatically configure the Quartz scheduler. Then in another startup class you can retrieve that scheduler, add jobs and begin serving those jobs.

You generally don't need to worry about the threadpool, Quartz can handle all this itself if you want it too. It gets its information from a properties files on startup that you can define or use the default one that comes with quartz. I have been using the default because it works for my purposes.

As far as defining jobs, you create your job classes and call your ejbs from there. It is rather very simple.

For your reading pleasure:

All Quartz documentation

Quartz JavaDoc

Cookbook containing lots of code snippets

Hope that's enough to get you started!

Poindexter
+1  A: 

Great news! JBoss has a built-in scheduler already.

Since the EJB 2.0 specification included running stateless session beans and MDBs at scheduled intervals, all application servers have included this capability for some time now.

Here is an example of configuring JBoss to run a class using its built-in scheduler:

http://www.jboss.org/community/wiki/Scheduler

The best part about JBoss' implementation is that it is based on the MBean specification, which means that you can create/update/delete scheduled tasks at runtime.

shadit
A: 

As pointed out by Poindexter, the Quartz documentation has nice starting points: Tutorial for Developing with Quartz, Examples of Usage, Cook Book (Quick How-Tos in the form of code examples), etc.

The What Is Quartz article is really good too (even if a bit old now).

For integration with JBoss, maybe have a look at How to configure a Quartz service on JBoss Wiki.

Pascal Thivent
+1  A: 

Ok, i am sorry, i found in the sources of Jboss Seam just what i needed : QuartzDispatcher to create QuartzTriggerHandle wich fires seam event at specified time and date and is manually pausable, resumable and stoppable. I use an @observer on the method i wanted to execute.

It's simple, and it works so far.

Maxime ARNSTAMM
A: 

Poindexter, I have an enterprise ejb 3.0 application that deploys on weblogic 10. I have no front end just back end. I need to setup quartz at startup to schedule a job via cron trigger, this job is a method invoked on one of my stateless session beans to browse a jms queue.

From all those links you attached and looking at ejb timer, i cant see how i can do this without having front end (web.xml) or scheduling the job myself manually somehow.

I see in ejb 3.1 there exists an auto timer that runs from the time the bean is deployed. All you need is a @Schedule annotation on the method, how easy is that!

Can you explain how in my application i can setup a startup class to configure the quartz scheduler or achieve my goal?

Thanks, Shane.

shane lee