1 Reply Latest reply on Jun 8, 2013 9:26 AM by Wolf-Dieter Fink

    [JBoss 5.1 GA & EJB 3.0] configure ejb2-timer-service.xml to support both persistence and non persistence EJB timers

    bunty lava Newbie

      I want to configure ejb2-timer-service.xml to support both persistence and non persistence timers,

       

      To do this, I have made the following change in the ejb2-timer-service.xml.

      - ========================================================================================================================================

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

      <server>

        <mbean code="org.jboss.ejb.txtimer.DatabasePersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=database">

          <!-- DataSourceBinding ObjectName -->

          <depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>

          <!-- The plugin that handles database persistence -->

          <attribute name="DatabasePersistencePlugin">org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin</attribute>

          <!-- The timers table name -->

          <attribute name="TimersTable">TIMERS</attribute>

          <depends>jboss.jdbc:datasource=DefaultDS,service=metadata</depends>

        </mbean>

       

         <!-- A retry policy that uses a fixed interval in milli seconds -->

         <mbean code="org.jboss.ejb.txtimer.FixedDelayRetryPolicy" name="jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay">

           <attribute name="Delay">100</attribute>

         </mbean>

       

        <!-- An EJB Timer Service that is Tx aware -->

        <mbean code="org.jboss.ejb.txtimer.EJBTimerServiceImpl"

          name="jboss.ejb:service=EJBTimerService">

          <attribute name="TimerIdGeneratorClassName">org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator</attribute>

          <attribute name="TimedObjectInvokerClassName">org.jboss.ejb.txtimer.TimedObjectInvokerImpl</attribute>

          <depends optional-attribute-name="RetryPolicy">jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay</depends>

          <depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=database</depends>

          <depends optional-attribute-name="TransactionManagerFactory" proxy-type="org.jboss.tm.TransactionManagerFactory">

            jboss:service=TransactionManager

          </depends>   

        </mbean>

       

      <!-- MY CHANGE Start -->


      <!-- A persistence policy that does not persist the timer->

        <mbean code="org.jboss.ejb.txtimer.NoopPersistencePolicy" name="jboss.ejb:service=NoopEJBTimerService,persistencePolicy=noop"/>

       

        

         <!-- A retry policy that uses a fixed interval in milli seconds -->

         <mbean code="org.jboss.ejb.txtimer.FixedDelayRetryPolicy" name="jboss.ejb:service=NoopEJBTimerService,retryPolicy=fixedDelay">

           <attribute name="Delay">100</attribute>

         </mbean>

       

        <!-- An EJB Timer Service that is noop -->

        <mbean code="org.jboss.ejb.txtimer.EJBTimerServiceImpl"

          name="jboss.ejb:service=NoopEJBTimerService">

          <attribute name="TimerIdGeneratorClassName">org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator</attribute>

          <attribute name="TimedObjectInvokerClassName">org.jboss.ejb.txtimer.TimedObjectInvokerImpl</attribute>

          <depends optional-attribute-name="RetryPolicy">jboss.ejb:service=NoopEJBTimerService,retryPolicy=fixedDelay</depends>

          <depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=NoopEJBTimerService,persistencePolicy=noop</depends>

          <depends optional-attribute-name="TransactionManagerFactory" proxy-type="org.jboss.tm.TransactionManagerFactory">

            jboss:service=TransactionManager

          </depends>   

        </mbean>

       

      <!-- MY CHANGE END-->

      </server>

       

      ========================================================================================================================================

       

      In the EJB class, I have define @Resource annotation for timerservice field with name as jboss.ejb:service=NoopEJBTimerService.

       

      eg :

      @Resource(name="jboss.ejb:service=NoopEJBTimerService")

      TimerService timerService;

       

      The EJB deployment is successfull, but it is still considering the persistence timer.

       

      On the server console, there is a warning saying

       

      cannot resolve resource: jboss.ejb:service=NoopEJBTimerService

      failed to resolve resource jboss.ejb:service=NoopEJBTimerService

       

      CAN ANYONE HELP ME WITH WHAT I AM DOIN WRONG.

       

      Thanks in advance