QuartzプラグインをGrailsでクラスタ化するには、プロジェクトに含める必要があるファイルがいくつかあります。まず、grails-app/conf/QuartzConfig.groovy
をインストールし、jdbcStore
が有効になっていることを確認します。
quartz {
autoStartup = true
jdbcStore = true
waitForJobsToCompleteOnShutdown = true
}
次に、接続先のデータベースに関連するHibernate設定ファイルをインストールします。たとえば、Oracleで、grails-app/conf/hibernate/hibernate.cfg.xml
のベースにHibernate XML設定は次のとおりです。この例の
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
'-//Hibernate/Hibernate Configuration DTD 3.0//EN'
'http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd'>
<hibernate-configuration>
<session-factory>
<mapping resource="Quartz.oracle.hbm.xml"/>
</session-factory>
</hibernate-configuration>
実際のクォーツ・休止状態SQLファイルがQuartz.oracle.hbm.xml
という名前になりますと同じディレクトリに存在します。これらのファイルは、GitHub(https://github.com/nebolsin/grails-quartz)のQuartzプラグインのsrc/templates/sql
にあります。これらのスクリプトは、DataSource create
とcreate-drop
でのみ動作するように見えるので、前回の実行でまだ存在していない場合は、update
に手動でQuartzテーブルを作成する必要があります。
は
grails-app/conf/quartz/quartz.properties
ファイルを作成し、編集するには、ビジネスニーズに合わせてある:上記のプロパティから
/* Have the scheduler id automatically generated for
* all schedulers in a cluster */
org.quartz.scheduler.instanceId = AUTO
/* Don't let Quartz "Phone Home" to see if new versions
* are available */
org.quartz.scheduler.skipUpdateCheck = true
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
/* Configure Quartz for only one thread as the only job
* should run once per day */
org.quartz.threadPool.threadCount = 4
/* Give the thread a Thread.MIN_PRIORITY level*/
org.quartz.threadPool.threadPriority = 1
/* Allow a minute (60,000 ms) of non-firing to pass before
* a trigger is called a misfire */
org.quartz.jobStore.misfireThreshold = 60000
/* Handle only 2 misfired triggers at a time */
org.quartz.jobStore.maxMisfiresToHandleAtATime = 2
/* Check in with the cluster every 5000 ms*/
org.quartz.jobStore.clusterCheckinInterval = 5000
/* Use the Oracle Quartz Driver to communicate via JDBC */
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
/* Have Quartz handle its own transactions with the database */
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
/* Define the prefix for the Quartz tables in the database*/
org.quartz.jobStore.tablePrefix = QRTZ_
/* Tell Quartz it is clustered */
org.quartz.jobStore.isClustered = true
/* Tell Quartz that properties passed to the job call are
* NOT all String objects */
org.quartz.jobStore.useProperties = false
/* Detect the jvm shutdown and call shutdown on the scheduler */
org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown = true
/* Log the history of triggers and jobs */
org.quartz.plugin.triggerHistory.class = org.quartz.plugins.history.LoggingTriggerHistoryPlugin
org.quartz.plugin.jobHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
注意が、あなたは関連する仕事やトリガトリガ情報をログに記録するConfig.groovy
のLog4jの設定でorg.quartz.plugins
を設定することができます。私はinfo
レベルで十分だと思います。
scripts/_Events.groovy
を編集または作成し、次の戦争修正クロージャを追加します。これにより、既知のQuartzプラグインのバグが修正され、プラグインの空白の代わりに正しいquartz.properties
が最終的なwarファイルにインストールされます。
eventCreateWarStart = { warName, stagingDir ->
// Make sure we have the correct quartz.properties in the
// correct place in the war to enable clustering
ant.delete(dir:"${stagingDir}/WEB-INF/classes/quartz")
ant.copy(file:"${basedir}/grails-app/conf/quartz/quartz.properties",
todir:"${stagingDir}/WEB-INF/classes")
}
そして、あなたが行われる必要があります...
P.S. Oracleデータベースを使用している場合は、クォーツ・オラクルの通信ドライバへのアクセス権を持っているように、依存関係のブロックにBuildConfig.groovy
に次の行を追加します。
runtime("org.quartz-scheduler:quartz-oracle:1.7.2") {
// Exclude quartz as 1.7.3 is included from the plugin
excludes('quartz')
}
PPSを上記のリンクでSQLファイルがありますちょうどSQL。、休止状態ファイルにそれを行うには、単に(再びワット/ Oracleの例)ので、同じように、Hibernate database-object
ノードと、個々のSQLコマンドを囲む:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
'-//Hibernate/Hibernate Mapping DTD 3.0//EN'
'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>
<hibernate-mapping>
<database-object>
<create>
CREATE TABLE QRTZ_JOB_DETAILS (
JOB_NAME VARCHAR2(200) NOT NULL,
JOB_GROUP VARCHAR2(200) NOT NULL,
DESCRIPTION VARCHAR2(250) NULL,
JOB_CLASS_NAME VARCHAR2(250) NOT NULL,
IS_DURABLE VARCHAR2(1) NOT NULL,
IS_VOLATILE VARCHAR2(1) NOT NULL,
IS_STATEFUL VARCHAR2(1) NOT NULL,
REQUESTS_RECOVERY VARCHAR2(1) NOT NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (JOB_NAME,JOB_GROUP)
)
</create>
<drop>DROP TABLE QRTZ_JOB_DETAILS</drop>
<dialect-scope name='org.hibernate.SomeOracleDialect' />
</database-object>
...
<database-object>
<create>INSERT INTO QRTZ_LOCKS VALUES('TRIGGER_ACCESS')</create>
<drop></drop>
<dialect-scope name='org.hibernate.SomeOracleDialect' />
</database-object>
...
</hibernate-mapping>
dialect-scope
は、データベースの作成およびドロップを方言いるとHibernateに伝えますノードを使用する必要があります。それを残して、それが機能するかどうかを調べることができます。そうしないと、Grails DataSourceで使用されるMySqlダイアレクトを追加する必要があります。
詳細な応答をありがとうございます。これはまさに私が探していた情報のように見えます。私はMySQLのDBとしてAmazonのRDSを使用しています。再度、感謝します。 –
私はQuartz.mysql.innodb.hbm.xmlというファイルを見つけることができませんでした。私はtables_mysql_innodb.sqlを見つけましたが、上のサンプルXMLコードでは、設定する必要があることを意味します。 –
Quartz.mysql.innodb.hbm.xmlというファイルを見つけることができませんでした。私はtables_mysql_innodb.sqlを見つけましたが、上記のサンプルXMLコードでは、 を設定する必要があります。私はgithubからチェックアウトされたすべてのコードを検索しましたが、そのようなXMLファイルはありません。私はお詫びしますが、私はすべてこれより新しいです。私のデータベースは、InnoDBを使ったAmazonのRDS MySQLです。これを理解するためには、QuartzとHibernateの設定をもっと深く理解しなければならないと思います。私は長い一日を過ごしました。おそらく、私は朝、これをすべて見ると意味をなさないでしょう! Thx –