Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 63. Quartz


Schedule sending of messages using the Quartz 2.x scheduler.

63.1. What’s inside

Please refer to the above link for usage and configuration details.

63.2. Maven coordinates

Create a new project with this extension on code.quarkus.redhat.com

Or add the coordinates to your existing project:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-quartz</artifactId>
</dependency>
Copy to Clipboard Toggle word wrap

63.3. Usage

63.3.1. Clustering

Support for Quartz clustering is provided by the Quarkus Quartz extension. The following 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.

    # 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
    Copy to Clipboard Toggle word wrap
  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.

    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-jdbc-postgresql</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-agroal</artifactId>
    </dependency>
    Copy to Clipboard Toggle word wrap
  3. Quarkus Flyway can automatically create the necessary Quartz database tables for you. Add quarkus-flyway to your application (optional).

    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-flyway</artifactId>
    </dependency>
    Copy to Clipboard Toggle word wrap

    Also add a Quartz database creation script for your chosen database kind. The Quartz project provides ready made scripts that can be copied from 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.

    @Produces
    @Singleton
    @Named("quartz")
    public QuartzComponent quartzComponent(Scheduler scheduler) {
        QuartzComponent component = new QuartzComponent();
        component.setScheduler(scheduler);
        return component;
    }
    Copy to Clipboard Toggle word wrap

Further customization of the Quartz scheduler can be done via various configuration properties. Refer to to the Quarkus Quartz Configuration guide for more information.

Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat