1 Şubat 2021 Pazartesi

SpringQuartz application.properties Ayarları

jobStore Alanı
İki tane alan mecburi. Açıklamalar burada
1. org.quartz.jobStore.dataSource
1. org.quartz.jobStore.driverDelegateClass

1. jobStore .dataSource
Örnek
Şöyle yaparız
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
spring.quartz.properties.org.quartz.jobStore.dataSource=CityTasksQuartzDS
Örnek
Şöyle yaparız
##Server Port
server.port = 8099

## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:postgresql://localhost:5432/scheduler
spring.datasource.username = postgres
spring.datasource.password = 

## QuartzProperties
spring.quartz.job-store-type = jdbc
spring.quartz.jdbc.initialize-schema = never
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
spring.quartz.properties.org.quartz.threadPool.threadCount = 5

2. jobStore .driverDelegateClass
Açıklaması şöyle
Adopt the driverDelegateClass to your database platform — just check the classes in the package org.quarzt.impl.jdbcjobstore to choose from.
Örnek - PostgreSQLDelegate
Şöyle yaparız
spring:
  quartz:
    job-store-type: jdbc
    jdbc:
      initialize-schema: never
    startup-delay: 60s
    properties:
       org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
store-type Alanı
MEMORY veya JDBC seçilebilir.  Açıklaması şöyle
Quartz comes with its own in-built JobStores, and if you need you can create your own by implementing org.quartz.spi.JobStore interface. In spring-boot quartz provides two JobStores

MEMORY— It keeps all of its data in RAM so once the application ends or crashes all the scheduling information is lost. Since it keeps its data in RAM, it is very fast and simple to configure

JDBC — JDBC JobStore keeps all of its data in a database via JDBC. Since it relies on database, configuration is a bit complicated and certainly is not as fast as RAM JobStore
store-type=JDBC 
JDBC kullanacaksak bir DataSource tanımlı olmalıdır. Açıklaması şöyle
If you need to manage jobs on your own and modify them time to time without effecting the up-time of your application you should move to the JDBC job store. You can run clustered or non-clustered scheduler service when using the JDBC job store.
Örnek - jdbc
Şöyle yaparız
spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=never
Örnek - jdbc
Şöyle yaparız. Burada datasource tanımı da var
spring.datasource.platform=org.hibernate.dialect.MySQL5Dialect
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/quartz_demo_db
spring.datasource.username=root
spring.datasource.password=admin
spring.jpa.open-in-view=false
spring.jpa.show-sql=true

spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=never
threadpool Alanı
Örnek
Şöyle yaparız
spring.quartz.job-store-type = jdbc
spring.quartz.properties.org.quartz.threadPool.threadCount = 5
instanceId Alanı
Açıklaması şöyle
Each Quartz Scheduler must has a unique ID. The value can be any string but must be unique for all schedulers. If we need we can AUTO generate this id by adding the property
Örnek
Şöyle yaparız
#QUARTZ CONFIGS
spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=never

spring.quartz.properties.org.quartz.scheduler.instanceName=quartz-demo-app
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.scheduler.instanceIdGenerator.class=com.helixz.quartz.demo.component.CustomQuartzInstanceIdGenerator
spring.quartz.properties.org.quartz.threadPool.threadCount=20
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
spring.quartz.properties.org.quartz.jobStore.useProperties=true
spring.quartz.properties.org.quartz.jobStore.misfireThreshold=60000
spring.quartz.properties.org.quartz.jobStore.tablePrefix=qrtz_
spring.quartz.properties.org.quartz.jobStore.isClustered=true
spring.quartz.properties.org.quartz.plugin.shutdownHook.class=org.quartz.plugins.management.ShutdownHookPlugin
spring.quartz.properties.org.quartz.plugin.shutdownHook.cleanShutdown=TRUE
quartz.properties Dosyası
Eğer tüm ayarları application.properties dosyasına doldurmak istemiyorsak quartz.properties dosyası da kullanılabilir.
Örnek
Şöyle yaparız
org.quartz.scheduler.instanceName=sample
org.quartz.scheduler.instanceId=AUTO
org.quartz.scheduler.rmi.export=false
org.quartz.scheduler.rmi.proxy=false
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=3
org.quartz.context.key.QuartzTopic=QuartzProperties
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.isClustered=true

org.quartz.jobStore.dataSource=sample

org.quartz.dataSource.sample.provider=hikaricp
org.quartz.dataSource.sample.URL = jdbc:h2:mem:test;MODE=MySQL
org.quartz.dataSource.sample.driver = org.h2.Driver
serverTimezone=UTC&characterEncoding=UTF-8
org.quartz.dataSource.sample.user = sa


Hiç yorum yok:

Yorum Gönder