diff --git a/Others/quartz/README.md b/Others/quartz/README.md new file mode 100644 index 0000000000000000000000000000000000000000..78f2b0784ca453f774469077c7723cf92ba727a5 --- /dev/null +++ b/Others/quartz/README.md @@ -0,0 +1,104 @@ +# Quick reference + +- The official quartz docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative). + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community). + +# quartz | openEuler +Current quartz docker images are built on the [openEuler](https://repo.openeuler.org/). This repository is free to use and exempted from per-user rate limits. + +Quartz is a richly featured, open source job scheduling library that can be integrated within virtually any Java application - from the smallest stand-alone application to the largest e-commerce system. + +Learn more about quartz on [quartz documentation](https://www.quartz-scheduler.org/documentation/)⁠. + +# Supported tags and respective Dockerfile links +The tag of each `quartz` docker image is consist of the version of `quartz` and the version of basic image. The details are as follows + +| Tag | Currently | Architectures | +|----------|-------------|------------------| +|[2.5.0-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/quartz/2.5.0/24.03-lts-sp1/Dockerfile)| quartz 2.5.0 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + +# Usage +In this usage, users can select the corresponding `{Tag}` based on their requirements. + +- Add quartz dependency + + Maven: Add the following dependency to your `pom.xml`. + ``` + + org.quartz-scheduler + quartz + ${quartz.version} + + ``` + +- Define a Job + + Create a class that implements `Job` interface: + ``` + package com.example; + + import org.quartz.Job; + import org.quartz.JobDataMap; + import org.quartz.JobExecutionContext; + import org.quartz.JobExecutionException; + + public class SimpleJob implements Job { + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + System.out.println("SimpleJob is executed at: " + new java.util.Date()); + + JobDataMap dataMap = context.getJobDetail().getJobDataMap(); + String jobParam = dataMap.getString("jobParam"); + if(jobParam != null) { + System.out.println("Job parameter: " + jobParam); + } + } + } + ``` + +- Schedule the job + + ``` + package com.example; + + import org.quartz.*; + import org.quartz.impl.StdSchedulerFactory; + + public class QuartzDemo { + public static void main(String[] args) { + try { + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + + JobDetail job = JobBuilder.newJob(SimpleJob.class) + .withIdentity("job1", "group1") + .usingJobData("jobParam", "Hello, Quartz!") + .build(); + + Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity("trigger1", "group1") + .startNow() + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(5) + .repeatForever()) + .build(); + + scheduler.scheduleJob(job, trigger); + + scheduler.start(); + + while (true) { + Thread.sleep(1000); + } + + } catch (SchedulerException | InterruptedException e) { + e.printStackTrace(); + } + } + } + ``` + +# Question and answering +If you have any questions or want to use some special features, please submit an issue or a pull request on [openeuler-docker-images](https://gitee.com/openeuler/openeuler-docker-images). \ No newline at end of file diff --git a/Others/quartz/doc/image-info.yml b/Others/quartz/doc/image-info.yml new file mode 100644 index 0000000000000000000000000000000000000000..c4471ef1acf3e0b1637a06e1a781c76041ef4866 --- /dev/null +++ b/Others/quartz/doc/image-info.yml @@ -0,0 +1,104 @@ +name: quartz +category: others +description: Quartz 是一个开源的 Java 任务调度框架,用于在应用程序中实现定时任务、周期性任务或复杂调度需求。 +environment: | + 本应用在Docker环境中运行,安装Docker执行如下命令 + ``` + yum install -y docker + ``` +tags: | + quartz镜像的Tag由其版本信息和基础镜像版本信息组成,详细内容如下 + + | Tag | Currently | Architectures | + |----------|-------------|------------------| + |[2.5.0-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/quartz/2.5.0/24.03-lts-sp1/Dockerfile)| quartz 2.5.0 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + +download: | + 拉取镜像到本地 + ``` + docker pull openeuler/quartz:{Tag} + ``` + +usage: | + - Add quartz dependency + + Maven: Add the following dependency to your `pom.xml`. + ``` + + org.quartz-scheduler + quartz + ${quartz.version} + + ``` + + - Define a Job + + Create a class that implements `Job` interface: + ``` + package com.example; + + import org.quartz.Job; + import org.quartz.JobDataMap; + import org.quartz.JobExecutionContext; + import org.quartz.JobExecutionException; + + public class SimpleJob implements Job { + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + System.out.println("SimpleJob is executed at: " + new java.util.Date()); + + JobDataMap dataMap = context.getJobDetail().getJobDataMap(); + String jobParam = dataMap.getString("jobParam"); + if(jobParam != null) { + System.out.println("Job parameter: " + jobParam); + } + } + } + ``` + + - Schedule the job + + ``` + package com.example; + + import org.quartz.*; + import org.quartz.impl.StdSchedulerFactory; + + public class QuartzDemo { + public static void main(String[] args) { + try { + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + + JobDetail job = JobBuilder.newJob(SimpleJob.class) + .withIdentity("job1", "group1") + .usingJobData("jobParam", "Hello, Quartz!") + .build(); + + Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity("trigger1", "group1") + .startNow() + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(5) + .repeatForever()) + .build(); + + scheduler.scheduleJob(job, trigger); + + scheduler.start(); + + while (true) { + Thread.sleep(1000); + } + + } catch (SchedulerException | InterruptedException e) { + e.printStackTrace(); + } + } + } + ``` + +license: Apache-2.0 license +similar_packages: + - Spring Scheduler: Spring Scheduler 是 Spring 框架内置的轻量级任务调度模块,通过简单的注解即可实现定时任务,无需额外依赖。 +dependency: + - openjdk diff --git a/Others/quartz/doc/picture/logo.png b/Others/quartz/doc/picture/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..cbee9893a84c3be9f0a6b1cb3b49b1ddf8af1ce8 Binary files /dev/null and b/Others/quartz/doc/picture/logo.png differ