Skip to content

Commit

Permalink
#29479 Implement PostgresJobQueue and related error handling classes
Browse files Browse the repository at this point in the history
This commit adds a PostgreSQL-specific implementation of the JobQueue interface, providing detailed methods for job management using a PostgreSQL database. It also introduces new error handling classes like JobQueueException, JobQueueDataException, and renames ProcessorNotFoundException to JobProcessorNotFoundException for clarity.
  • Loading branch information
jgambarios committed Sep 18, 2024
1 parent c8a91cd commit 7cd30ce
Show file tree
Hide file tree
Showing 15 changed files with 928 additions and 135 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.dotcms.jobs.business.api;

import com.dotcms.jobs.business.error.CircuitBreaker;
import com.dotcms.jobs.business.error.JobCancellationException;
import com.dotcms.jobs.business.error.ProcessorNotFoundException;
import com.dotcms.jobs.business.error.JobProcessorNotFoundException;
import com.dotcms.jobs.business.error.RetryStrategy;
import com.dotcms.jobs.business.job.Job;
import com.dotcms.jobs.business.processor.JobProcessor;
import com.dotmarketing.exception.DotDataException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -62,35 +62,38 @@ public interface JobQueueManagerAPI extends AutoCloseable {
* @param queueName The name of the queue
* @param parameters The parameters for the job
* @return The ID of the created job
* @throws ProcessorNotFoundException if no processor is registered for the specified queue
* @throws JobProcessorNotFoundException if no processor is registered for the specified queue
* @throws DotDataException if there's an error creating the job
*/
String createJob(String queueName, Map<String, Object> parameters)
throws ProcessorNotFoundException;
throws JobProcessorNotFoundException, DotDataException;

/**
* Retrieves a job by its ID.
*
* @param jobId The ID of the job
* @return The Job object, or null if not found
* @throws DotDataException if there's an error fetching the job
*/
Job getJob(String jobId);
Job getJob(String jobId) throws DotDataException;

/**
* Retrieves a list of jobs.
*
* @param page The page number
* @param pageSize The number of jobs per page
* @return A list of Job objects
* @throws DotDataException if there's an error fetching the jobs
*/
List<Job> getJobs(int page, int pageSize);
List<Job> getJobs(int page, int pageSize) throws DotDataException;

/**
* Cancels a job.
*
* @param jobId The ID of the job to cancel
* @throws JobCancellationException if the job cannot be cancelled
* @throws DotDataException if there's an error cancelling the job
*/
void cancelJob(String jobId) throws JobCancellationException;
void cancelJob(String jobId) throws DotDataException;

/**
* Registers a watcher for a specific job.
Expand Down
Loading

0 comments on commit 7cd30ce

Please sign in to comment.