0 Replies Latest reply on Mar 4, 2008 5:46 PM by Philippe Larouche

    Problem with quartz in JBoss

    Philippe Larouche Newbie

      Hi guys,

      I'm pretty new to quartz and what i'm trying to do is to create a job that I would deploy in jboss and would execute let's say, every five minutes. So far, what I have is a class that implement Job and also javax.ejb.MessageDrivenBean. My jboss.xml file looks like this:


      <?xml version="1.0" encoding="UTF-8"?>

      <enterprise-beans>
      <message-driven>
      <ejb-name>PatientCaseManager</ejb-name>
      <destination-jndi-name>dummy</destination-jndi-name>
      <resource-adapter-name>quartz-ra.rar</resource-adapter-name>
      </message-driven>
      </enterprise-beans>



      And my ejb-jar.xml looks like that:

      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
      <enterprise-beans>
      <message-driven>
      <ejb-name>PatientCaseManager</ejb-name>
      <ejb-class>com.myca.job.PatientCaseManager</ejb-class>
      <messaging-type>org.quartz.Job</messaging-type>
      <transaction-type>Container</transaction-type>
      <activation-config>
      <activation-config-property>
      <activation-config-property-name>cronTrigger</activation-config-proper ty-name>
      <activation-config-property-value><![CDATA[* 0/1 * * * ?]]></activation-config-property-value>
      </activation-config-property>
      </activation-config>
      </message-driven>
      </enterprise-beans>
      </ejb-jar>


      The problem is that when I start jboss, multiple threads are started and it seems like there are as many jobs scheduled as there are threads in jboss (i debugged and every 5 minutes, I receive about 10 request to the execute method). Is there a way to have the execute method executed only once???

      Here's my job class:

      public class PatientCaseManager implements Job, MessageDrivenBean
      {
      @Override
      public void execute(JobExecutionContext arg0) throws JobExecutionException
      {
      try
      {
      InitialContext cntx = new InitialContext();

      cntx.lookup("blabla");
      }
      catch(NamingException ex)
      {

      }
      }

      @Override
      public void setMessageDrivenContext(MessageDrivenContext arg0)
      throws EJBException
      {

      }

      @Override
      public void ejbRemove() throws EJBException
      {

      }


      public void ejbCreate()
      {
      String test= "test";
      }
      }



      Thx a lot!

      Korg