-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify support for Quartz clustering
Fixes #3850
- Loading branch information
1 parent
29b4455
commit a3e8105
Showing
26 changed files
with
624 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
= Camel Quarkus 2.11.0 Migration Guide | ||
|
||
The following guide outlines how to adapt your code to changes that were made in Camel Quarkus 2.11.0 & Quarkus 2.11.0.Final. | ||
|
||
== Changes to Quartz clustering support | ||
|
||
In previous releases the Camel Quarkus Quartz documention listed various means of configuring Quartz for clustering. This has now been simplified | ||
to a single set of instructions that leverages Quarkus Quartz. If you are using one of the previous methods of clustering, it is advised to update your | ||
application to the new method documented in the xref:reference/extensions/quartz.adoc[Quartz extension guide]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,73 @@ | ||
=== Clustering | ||
|
||
There are two options how to run Quartz in clustered mode: | ||
|
||
==== Quarkus based | ||
|
||
This is the preferred option. Follow the https://quarkus.io/guides/quartz[scheduling periodic tasks quartz guide]. | ||
|
||
- Define database configuration in `application.properties`. | ||
- Use for example `flyway` to create database tables required for `Quartz`. | ||
|
||
===== Quartz based with an Agroal datasource | ||
|
||
Follow the http://www.quartz-scheduler.org/documentation/quartz-1.8.6/configuration/ConfigJDBCJobStoreClustering.html#configure-clustering-with-jdbc-jobstore[Configure Clustering with JDBC-JobStore Guide] with different DS configuration: | ||
|
||
- Declare to use `io.quarkus:quarkus-agroal` in `pom.xml` explicitly. | ||
|
||
``` | ||
Support for Quartz clustering is provided by the Quarkus Quartz extension. The follow steps outline how to configure Quarkus Quartz for use with Camel. | ||
|
||
1. Enable Quartz clustered mode and configure a `DataSource` as a persistence Quartz job store. An example configuration is as follows. | ||
+ | ||
[source,properties] | ||
---- | ||
# Quartz configuration | ||
quarkus.quartz.clustered=true | ||
quarkus.quartz.store-type=jdbc-cmt | ||
quarkus.quartz.start-mode=forced | ||
# Datasource configuration | ||
quarkus.datasource.db-kind=postgresql | ||
quarkus.datasource.username=quarkus_test | ||
quarkus.datasource.password=quarkus_test | ||
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost/quarkus_test | ||
|
||
# Optional automatic creation of Quartz tables | ||
quarkus.flyway.connect-retries=10 | ||
quarkus.flyway.table=flyway_quarkus_history | ||
quarkus.flyway.migrate-at-start=true | ||
quarkus.flyway.baseline-on-migrate=true | ||
quarkus.flyway.baseline-version=1.0 | ||
quarkus.flyway.baseline-description=Quartz | ||
---- | ||
|
||
2. Add the correct JDBC driver extension to your application that corresponds to the value of `quarkus.datasource.db-kind`. In the above | ||
example `postgresql` is used, therefore the following JDBC dependency would be required. Adjust as necessary for your needs. Agroal is also required | ||
for `DataSource` support. | ||
+ | ||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jdbc-postgresql</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-agroal</artifactId> | ||
</dependency> | ||
``` | ||
|
||
- Use `quartz.properties` to configure the `JobStore`. | ||
- Define a datasource via quarkus (see the https://quarkus.io/guides/datasource[Quarkus datasource documentation)] and use `CamelQuarkusQuartzConnectionProvider` as the `ConnectionProvider` in `quartz.properties`: | ||
---- | ||
``` | ||
... | ||
org.quartz.jobStore.dataSource = myDS | ||
|
||
# datasource configuration | ||
org.quartz.dataSource.myDS.connectionProvider.class = org.apache.camel.quarkus.component.quartz.CamelQuarkusQuartzConnectionProvider | ||
org.quartz.dataSource.myDSB.dataSourceName = ds_name_if_not_set_default_ds_will_be_used | ||
``` | ||
|
||
|
||
- You can use for example `flyway` to create database tables required for `Quartz`. | ||
|
||
===== Quartz based | ||
|
||
You can follow the http://www.quartz-scheduler.org/documentation/quartz-1.8.6/configuration/ConfigJDBCJobStoreClustering.html#configure-clustering-with-jdbc-jobstore[Configure Clustering with JDBC-JobStore Guide] without any modification: | ||
|
||
``` | ||
... | ||
org.quartz.jobStore.dataSource = myDS | ||
|
||
# datasource configuration | ||
org.quartz.dataSource.myDS.driver = org.postgresql.Driver | ||
|
||
# datasource configuration | ||
org.quartz.dataSource.myDS.URL=jdbc:postgresql://localhost:5432/default | ||
org.quartz.dataSource.myDS.user = quarkus | ||
org.quartz.dataSource.myDS.password = quarkus | ||
``` | ||
3. https://quarkus.io/guides/flyway[Quarkus Flyway] can automatically create the necessary Quartz database tables for you. Add `quarkus-flyway` to your application (optional). | ||
+ | ||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-flyway</artifactId> | ||
</dependency> | ||
---- | ||
+ | ||
Also add a Quartz database creation script for your chosen database kind. | ||
The Quartz project provides ready made scripts that can be copied from https://github.com/quartz-scheduler/quartz/tree/master/quartz-core/src/main/resources/org/quartz/impl/jdbcjobstore[here]. Add the SQL | ||
script to `src/main/resources/db/migration/V1.0.0__QuarkusQuartz.sql`. Quarkus Flyway will detect it on startup and will proceed to create the Quartz database tables. | ||
4. Configure the Camel Quartz component to use the Quarkus Quartz scheduler. | ||
+ | ||
[source,java] | ||
---- | ||
@Produces | ||
@Singleton | ||
@Named("quartz") | ||
public QuartzComponent quartzComponent(Scheduler scheduler) { | ||
QuartzComponent component = new QuartzComponent(); | ||
component.setScheduler(scheduler); | ||
return component; | ||
} | ||
---- | ||
Further customization of the Quartz scheduler can be done via various configuration properties. Refer to to the https://quarkus.io/guides/quartz#quartz-configuration-reference[Quarkus Quartz Configuration] guide for more information. |
66 changes: 0 additions & 66 deletions
66
.../java/org/apache/camel/quarkus/component/quartz/CamelQuarkusQuartzConnectionProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.