Tuesday, August 7, 2012

Quartz Integration On Oracle Weblogic


Quartz Integration On Oracle Weblogic


1. Pre-requisite for quartz integration


Pre-requisite to integrate quartz on WebLogic are as follows
1. Oracle WebLogic installed
2. Oracle/Database installed for connectivity
3. Application classes/jars, database connectivity drivers ( ojdbc14.jar )
4. JDK 1.6.0.3 or above


2. Starting Quartz on Oracle Weblogic (Windows Platform)


Before starting the application server, perform the following steps


1.  Place the following jars/files in following directory
Installed Drive\Oracle\Middleware\user_projects\domains\testdomain\lib
    org.jar
    custom.jar
    com.jar
    jta-1_1-classes.jar
    quartz-weblogic-2.1.5.jar
    QuartzScheduler.cfg


2.  Place the log4j.xml file in following directory
Installed Drive\Oracle\Middleware\user_projects\domains\testdomain


Note : "testdomain" in above path is the domain created while installing weblogic


3. Configuration changes


    QuartzScheduler.cfg


FileLogHeartbeats=Y ScreenLogShowHeartBeats=Y scriptFile=Framewrk/subs/json.lib,Framewrk/subs/filter.js,Framewrk/subs/da te.lib,Framewrk/common/FuncUtils.jds,Framewrk/common/dbUtils.jds,Frame wrk/common/DBSchema.js,Framewrk/subs/common.lib,Framewrk/main.jds orgMsgLogPath=C:/log serverPath=E:/Weblogic/weblogicwar/mfx_4_1_0_retail.war jndiName=mfx_4_1_0_retail_xa


FileLogHeartbeats : Log the quartz instance ScreenLogShowHeartBeats : On weblogic console show the quartz log scriptFile : Applications files to be loaded in quartz instance orgMsgLogPath : System path to log quartz info
serverPath : Path of application
jndiName : JNDI name used to connect to the deployed application.


Note : jndiName is the name of the data source created to connect to the application




4.  Changes in application web.xml file


Path : Path to WAR\WAR Name\WEB-INF
Add the following tag and details to web.xml file inside the <web-app> tag
<servlet>
<servlet-name>QuartzInitializer</servlet-name>
<servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-cla


ss>



<init-param>

aram-name>shutdown-on-unload</param-name>

aram-value>true</param-value>
</init-param>
<init-param>



aram-name>start-scheduler-on-load</param-name>

aram-value>true</param-value>
</init-param>
<init-param>

aram-name>config-file</param-name>

aram-value>quartz.properties</param-value>
</init-param>
oad-on-startup>1</load-on-startup>


</servlet>


Note : If these changes are not made in the web.xml file of the application, the quartz scheduler will not run for the deployed application


5.  Place the "quartz.properties" file in deployed application


Path : Path to WAR\WAR Name\WEB-INF
    Quartz.properties


#=============================================================
# Configure Main Scheduler Properties
#=============================================================


org.quartz.scheduler.instanceName = QuartzScheduler org.quartz.scheduler.rmi.export = false org.quartz.scheduler.rmi.proxy = false org.quartz.scheduler.xaTransacted = false
#org.quartz.scheduler.instanceId = AUTO


#=============================================================
# Configure ThreadPool
#=============================================================


org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount = 100 org.quartz.threadPool.threadPriority = 4


org.quartz.scheduler.logger = schedLogger org.quartz.logger.schedLogger.class = org.quartz.impl.Log4jLogger


#=============================================================
# Configure JobStore
#=============================================================


org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
org.quartz.jobStore.driverDelegateClass =
org.quartz.impl.jdbcjobstore.StdJDBCDelegate


org.quartz.jobStore.dataSource = mfx_4_1_0_retail_xa
org.quartz.jobStore.tablePrefix = QRTZ_


#=============================================================
# Configure Datasources
#============================================================= org.quartz.dataSource.mfx_4_1_0_retail_xa.jndiURL = mfx_4_1_0_retail_xa org.quartz.jobStore.nonManagedTXDataSource = mfx_4_1_0_retail_xa org.quartz.jobStore.maxMisfiresToHandleAtATime=60000


org.quartz.plugin.triggHistory.class =
\org.quartz.plugins.history.LoggingTriggerHistoryPlugin
org.quartz.plugin.triggHistory.triggerFiredMessage = \Trigger \{1\}.\{0\} fired job \{6\}.\{5\} at: \{4, date, HH:mm:ss MM/dd/yyyy}
org.quartz.plugin.triggHistory.triggerCompleteMessage = \ Trigger \{1\}.\{0\}
completed firing job \{6\}.\{5\} at \{4, date, HH:mm:ss MM/dd/yyyy\}.


Configuration changes to be made
    Configure JobStore Section
Properties
org.quartz.jobStore.dataSource - Name of the data source created in weblogic to connect to the database


    Configure Datasources Section
Properties
org.quartz.dataSource.mfx_4_1_0_retail_xa.jndiURL = mfx_4_1_0_retail_xa org.quartz.jobStore.nonManagedTXDataSource = mfx_4_1_0_retail_xa


mfx_4_1_0_retail_xa in above properties is the data source name


6.  Weblogic environment settings changes for quartz integration
    Open the "setDomainEnv.cmd" file and add the following code snippet
Path : Installed
Drive\Oracle\Middleware\user_projects\domains\testdomain\bin
Snippet :
Search for "LOG4J_CONFIG_FILE%" in the file and before that line add the following snippet
    set
LOG4J_CONFIG_FILE="E:/Oracle/Middleware/user_projects/domains/c
redence/log4j.xml"
This is the path to log4j.xml file that we placed in weblogic above in the guide.


7.  Once the above changes are done restart the weblogic server and you will see
following messages flashing on weblogic console indicating the quartz status


No comments: