diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java index 367a8b5e2fb1..69f3fae9eaf5 100644 --- a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java @@ -33,36 +33,38 @@ *
{@code * public static void main(String[] args) { * - * // Create the job queue - * JobQueue jobQueue = new PostgresJobQueue(); + * // Create the job queue + * JobQueue jobQueue = new PostgresJobQueue(); * - * // Create and start the job queue manager - * JobQueueManagerAPIImpl jobQueueManagerAPI = new JobQueueManagerAPIImpl(jobQueue, 5); // 5 threads + * // Create and start the job queue manager + * JobQueueManagerAPIImpl jobQueueManagerAPI = new JobQueueManagerAPIImpl(jobQueue, 5); // 5 threads * - * //(Optional) Set up a retry strategy for content import jobs - * RetryStrategy contentImportRetryStrategy = new ExponentialBackoffRetryStrategy(5000, 300000, 2.0, 3); - * contentImportRetryStrategy.addRetryableException(IOException.class); - * jobQueueManagerAPI.setRetryStrategy("contentImport", contentImportRetryStrategy); + * // (Optional) Set up a retry strategy for content import jobs, if not set, the default retry strategy will be used + * RetryStrategy contentImportRetryStrategy = new ExponentialBackoffRetryStrategy( + * 5000, 300000, 2.0, 3 + * ); + * contentImportRetryStrategy.addRetryableException(IOException.class); + * jobQueueManagerAPI.setRetryStrategy("contentImport", contentImportRetryStrategy); * - * // Register job processors - * jobQueueManagerAPI.registerProcessor("contentImport", new ContentImportJobProcessor()); + * // Register job processors + * jobQueueManagerAPI.registerProcessor("contentImport", new ContentImportJobProcessor()); * - * // Start the job queue manager - * jobQueueManagerAPI.start(); + * // Start the job queue manager + * jobQueueManagerAPI.start(); * - * // Create a content import job (dummy example) - * Map*/ diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/error/ExponentialBackoffRetryStrategy.java b/dotCMS/src/main/java/com/dotcms/jobs/business/error/ExponentialBackoffRetryStrategy.java index 58bbacfbe07b..991c2012b31b 100644 --- a/dotCMS/src/main/java/com/dotcms/jobs/business/error/ExponentialBackoffRetryStrategy.java +++ b/dotCMS/src/main/java/com/dotcms/jobs/business/error/ExponentialBackoffRetryStrategy.java @@ -88,23 +88,11 @@ public long nextRetryDelay(final Job job) { return delay + jitter; } - /** - * Returns the maximum number of retry attempts allowed by this strategy. - * - * @return The maximum number of retries. - */ @Override public int maxRetries() { return maxRetries; } - /** - * Determines whether a given exception is considered retryable according to the retry - * strategy. - * - * @param exception The exception to check if it is retryable. - * @return {@code true} if the exception is retryable, {@code false} otherwise. - */ @Override public boolean isRetryableException(final Throwable exception) { if (exception == null) { @@ -116,20 +104,12 @@ public boolean isRetryableException(final Throwable exception) { return retryableExceptions.stream().anyMatch(clazz -> clazz.isInstance(exception)); } - /** - * Adds an exception class to the set of retryable exceptions. - * - * @param exceptionClass The exception class to be considered retryable. - */ + @Override public void addRetryableException(final Class extends Throwable> exceptionClass) { retryableExceptions.add(exceptionClass); } - /** - * Returns an unmodifiable set of the currently registered retryable exceptions. - * - * @return An unmodifiable set of retryable exception classes. - */ + @Override public SetjobParameters = new HashMap<>(); - * jobParameters.put("filePath", "/path/to/import/file.csv"); - * jobParameters.put("contentType", "Article"); - * String jobId = jobQueueManagerAPI.createJob("contentImport", jobParameters); + * // Create a content import job (dummy example) + * Map jobParameters = new HashMap<>(); + * jobParameters.put("filePath", "/path/to/import/file.csv"); + * jobParameters.put("contentType", "Article"); + * String jobId = jobQueueManagerAPI.createJob("contentImport", jobParameters); * - * // Optionally, watch the job progress - * jobQueueManagerAPI.watchJob(jobId, job -> { - * System.out.println("Job " + job.id() + " progress: " + job.progress() * 100 + "%"); - * }); + * // Optionally, watch the job progress + * jobQueueManagerAPI.watchJob(jobId, job -> { + * System.out.println("Job " + job.id() + " progress: " + job.progress() * 100 + "%"); + * }); * - * // When shutting down the application - * jobQueueManagerAPI.close(); + * // When shutting down the application + * jobQueueManagerAPI.close(); * } * }