2009年10月14日水曜日

groovyとPostgreSQLとquartzの組み合わせでジョブを一覧表示する

groovyとPostgreSQLとquartzの組み合わせでジョブを一覧表示するには、以下のコードを実行します。


import org.quartz.*
import org.quartz.impl.*

// スケジューラ取得
//sf = new StdSchedulerFactory()
sf = new StdSchedulerFactory("./myquartz.properties")
sched = sf.getScheduler()

jobGroupNames = sched.getJobGroupNames()
println("total number of job group names:" + jobGroupNames.length)
for( jobGroupName in jobGroupNames ){
println("job group name:" + jobGroupName)
// ジョブを取得
jobNames = sched.getJobNames(jobGroupName)
for( jobName in jobNames ){
println("job name:" + jobName)
}
}
sched.shutdown(true)


設定ファイル(myquartz.properties)

org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true

org.quartz.jobStore.misfireThreshold = 60000

#org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX

# データソースの設定
org.quartz.dataSource.QuartzDS.driver = org.postgresql.Driver
org.quartz.dataSource.QuartzDS.URL = jdbc:postgresql://localhost:5432/quartz
org.quartz.dataSource.QuartzDS.user = postgres
org.quartz.dataSource.QuartzDS.password = postgres
org.quartz.dataSource.QuartzDS.maxConnections = 10
org.quartz.dataSource.QuartzDS.validationQuery = select 1

# JDBC JobStore設定
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.dataSource = QuartzDS
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.isClustered = false
org.quartz.jobStore.clusterCheckinInterval = 15000
org.quartz.jobStore.maxMisfiresToHandleAtATime = 20
org.quartz.jobStore.dontSetAutoCommitFalse = false
org.quartz.jobStore.selectWithLockSQL = SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE
org.quartz.jobStore.txIsolationLevelSerializable = false
org.quartz.jobStore.acquireTriggersWithinLock = false

0 件のコメント:

コメントを投稿