4 Replies Latest reply on Jul 29, 2008 12:34 PM by atijms

    Controlling the quartz scheduler from EJB with the quartz RA

    henk53

      Hi,

      In this topic (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=135323) I read the following:

      For the inbound adapter there is an interaction from EIS to AS , the messages are utilized by the endpoints which are of type MDB . Quartz is of this type , it is basically the inbound type adapter .


      I wonder, if quartz is only an inbound type adapter, does this mean it's impossible to programmatically create new jobs/triggers or to query the quartz scheduler for the currently scheduled jobs?

      In regular quartz, I can do something like this:

      SchedulerFactory factory = (SchedulerFactory)servletContext.getAttribute(QuartzInitializerListener.QUARTZ_FACTORY_KEY);
      Scheduler scheduler = factory.getScheduler();
      for ( String jobGroupName : scheduler.getJobGroupNames() ) {
       // ...
      }
      


      If I needed such kinds of interactions from my code to quartz from within an EJB bean, how would I go about doing that using the quartz RA?

        • 1. Re: Controlling the quartz scheduler from EJB with the quart
          vickyk

           

          "henk53" wrote:

          If I needed such kinds of interactions from my code to quartz from within an EJB bean, how would I go about doing that using the quartz RA?

          Have you tried using the JobExecutionContext to get the Schedule etc ... , I can see that it would be possible from the API
          http://quartz.sourceforge.net/javadoc/org/quartz/JobExecutionContext.html#method_summary

          • 2. Re: Controlling the quartz scheduler from EJB with the quart
            henk53

             

            "vickyk" wrote:
            "henk53" wrote:

            If I needed such kinds of interactions from my code to quartz from within an EJB bean, how would I go about doing that using the quartz RA?

            Have you tried using the JobExecutionContext to get the Schedule etc ... , I can see that it would be possible from the API
            http://quartz.sourceforge.net/javadoc/org/quartz/JobExecutionContext.html#method_summary


            That would indeed perhaps be an option if the job that was triggered by Quartz needed to programmatically schedule a new job. In my case however I need access to the scheduler to programmatically create a trigger and a job before any job has actually executed yet.

            My scenario is basically that a message arrives in a MDB and based on the content of that message a decision is made to schedule a job to run at e.g. a specific time. Therefor neither static annotations nor the context given to a job when it starts executing is really helpful.

            Some other option I thought about was letting quartz run in it's own web app within the same AS and letting it put a reference to the scheduler in JNDI when it starts up. That wise jobs will be triggered in the web app context and invoke EJB3 code in the EJB3 container. EJB3 code on its turn picks up the reference to the scheduler via JNDI and would use it to schedule new jobs dynamically.

            I wonder however whether there is some mechanism being provided by the quartz resource adapter for this.

            • 3. Re: Controlling the quartz scheduler from EJB with the quart
              henk53

              Nobody has any more ideas?

              • 4. Re: Controlling the quartz scheduler from EJB with the quart
                atijms

                I'm wondering about this too, but don't know the solution either.

                Maybe I'll have to look into the JCA specs and (if available) the current Quartz RA source code to see how challenging it is to add outflow capabilities to it. I'm afraid though that it probably won't be the easiest or fastest solution, so if anyone knows of something I would like to hear it too ;)