Elasticsearch Quartz Plugin is a scheduler for Elasticsearch plugins. In your Elasticsarch plugin, you can register a job and start it at a specified time.
$ $ES_HOME/bin/plugin -install org.codelibs/elasticsearch-quartz/1.0.1
To use ScheduleService, put the following dependency to your pom.xml.
<dependency>
<groupId>org.codelibs</groupId>
<artifactId>elasticsearch-quartz</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>
Quartz plugin provides ScheduleService instance to DI container(Guice) of Elasticsearch. Therefore, you can use scheduleService in your Service or River class as below:
@Inject
public YourRiver(final RiverName riverName, final RiverSettings settings,
final Client client, final ScheduleService scheduleService) {
...
ScheduleService delegates Scheduler's methods of Quartz.
ScheduleService allows you to register your Job and Trigger of Quartz.
scheduleService.scheduleJob(job, trigger);
You can remove your job by group and job ID.
import static org.quartz.JobKey.jobKey;
...
scheduleService.deleteJob(jobKey(jobId, groupId));