[jboss-user] [Beginners Corner] - Re: Call EJB on a Schedule?

l.tournayre do-not-reply at jboss.com
Mon Jul 24 11:46:36 EDT 2006


You can use quartz instead of a Timer in you MBean.

For using quartz you need two file :
in $JBOSS_HOME\server\default\lib\quartz-all-1.5.2.jar
org\quartz\ee\jmx\jboss\doc-files\quartz-service.xml-example

--> ..\deploy\quartz-service.xml

And you Quartz DS definition file:
quartz-ds.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
  | <!--  Datasource config for MySQL using 3.0.9 available from:
  | http://www.mysql.com/downloads/api-jdbc-stable.html
  | -->
  | 
  | <datasources>
  |   <local-tx-datasource>
  |     <jndi-name>QuartzDS</jndi-name>
  |     <connection-url>jdbc:mysql://xxxx:3306/quartz</connection-url>
  |     <driver-class>com.mysql.jdbc.Driver</driver-class>
  |     <user-name>quatrzUser</user-name>
  |     <password>xxxxx</password>
  |     <!--
  |     <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
  |     -->
  |     <new-connection-sql>SELECT CURDATE();</new-connection-sql>
  |     <check-valid-connection-sql>SELECT CURDATE();</check-valid-connection-sql>
  |     <!-- sql to call on an existing pooled connection when it is obtained from pool 
  |     <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
  |       -->
  | 
  |     <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
  |     
  |            <!-- Don't set this any higher than max_connections on your
  |          MySQL server, usually this should be a 10 or a few 10's
  |          of connections, not hundreds or thousands -->         
  |         <min-pool-size>1</min-pool-size>
  |         <max-pool-size>10</max-pool-size>
  | 
  |         <!-- Don't allow connections to hang out idle too long,
  |          never longer than what wait_timeout is set to on the
  |          server...A few minutes is usually okay here,
  |          it depends on your application
  |          and how much spikey load it will see -->
  | 
  |         <idle-timeout-minutes>5</idle-timeout-minutes>
  | 
  |         <!-- If you're using Connector/J 3.1.8 or newer, you can use
  |              our implementation of these to increase the robustness
  |              of the connection pool. -->
  | 
  |         <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
  |         <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
  |         
  |         
  |         
  |     <metadata>
  |        <type-mapping>mySQL</type-mapping>
  |     </metadata>
  |   </local-tx-datasource>
  | </datasources>
  | 

For creating the database schema see the quartz site.

After this you can use quartz in your MBean like this :

Regards,
Louis

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

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



More information about the jboss-user mailing list