diff --git a/CHANGELOG.md b/CHANGELOG.md index 436a353f..e928f978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.46.0 - 2024/11/26 + +### Added + +- Added `autoInitialize` property to enable/disable autoInitialization for job service, preventing registration and resumption when disabled. +- Added `startTasksCleaner` and `startTaskResumer` properties to switch on/off task cleaner and task resumer. + ## 1.45.0 - 2024/10/30 ### Changed diff --git a/gradle.properties b/gradle.properties index d4275f02..c4588e21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version=1.45.1 +version=1.46.0 org.gradle.internal.http.socketTimeout=120000 diff --git a/tw-tasks-core/src/main/java/com/transferwise/tasks/TasksProperties.java b/tw-tasks-core/src/main/java/com/transferwise/tasks/TasksProperties.java index 428a0f76..edaa13ad 100644 --- a/tw-tasks-core/src/main/java/com/transferwise/tasks/TasksProperties.java +++ b/tw-tasks-core/src/main/java/com/transferwise/tasks/TasksProperties.java @@ -331,6 +331,20 @@ public class TasksProperties { */ private boolean paranoidTasksCleaning = false; + /** + * If true, task cleaner will be started. + * + *

It starts to run task cleaner. + */ + private boolean startTasksCleaner = true; + + /** + * If true, task resumer will be started automatically. + * + *

It starts to run task resumer. + */ + private boolean startTaskResumer = true; + /** * How many tasks per bucket we are trying to grab at the same time. * diff --git a/tw-tasks-core/src/main/java/com/transferwise/tasks/cleaning/TasksCleaner.java b/tw-tasks-core/src/main/java/com/transferwise/tasks/cleaning/TasksCleaner.java index 896f7ebb..e38689ad 100644 --- a/tw-tasks-core/src/main/java/com/transferwise/tasks/cleaning/TasksCleaner.java +++ b/tw-tasks-core/src/main/java/com/transferwise/tasks/cleaning/TasksCleaner.java @@ -137,7 +137,9 @@ protected void deleteFinishedOldTasks() { @Override public void applicationStarted() { - leaderSelector.start(); + if (tasksProperties.isStartTasksCleaner()) { + leaderSelector.start(); + } } @Override diff --git a/tw-tasks-core/src/main/java/com/transferwise/tasks/stucktasks/TasksResumer.java b/tw-tasks-core/src/main/java/com/transferwise/tasks/stucktasks/TasksResumer.java index 7bf8eb59..d9071f4f 100644 --- a/tw-tasks-core/src/main/java/com/transferwise/tasks/stucktasks/TasksResumer.java +++ b/tw-tasks-core/src/main/java/com/transferwise/tasks/stucktasks/TasksResumer.java @@ -424,8 +424,10 @@ private ZonedDateTime getMaxStuckTime(ITaskProcessingPolicy taskProcessingPolicy @Override public void applicationStarted() { - executorServicesProvider.getGlobalExecutorService().submit(this::resumeTasksForClient); - leaderSelector.start(); + if (tasksProperties.isStartTaskResumer()) { + executorServicesProvider.getGlobalExecutorService().submit(this::resumeTasksForClient); + leaderSelector.start(); + } } @EntryPoint diff --git a/tw-tasks-jobs-test/src/main/java/com/transferwise/tasks/impl/jobs/test/TestJobsService.java b/tw-tasks-jobs-test/src/main/java/com/transferwise/tasks/impl/jobs/test/TestJobsService.java index de6df531..00ecc119 100644 --- a/tw-tasks-jobs-test/src/main/java/com/transferwise/tasks/impl/jobs/test/TestJobsService.java +++ b/tw-tasks-jobs-test/src/main/java/com/transferwise/tasks/impl/jobs/test/TestJobsService.java @@ -59,7 +59,9 @@ public boolean hasFinished(ExecuteAsyncHandle handle) { public void reset() { transactionsHelper.withTransaction().asNew().call(() -> { testTasksService.reset(); - initJobs(true); + if (jobsProperties.isAutoInitialize()) { + initJobs(true); + } return null; }); } diff --git a/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsProperties.java b/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsProperties.java index d7d751df..1fa80f06 100644 --- a/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsProperties.java +++ b/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsProperties.java @@ -13,4 +13,6 @@ public class JobsProperties { private String processingBucket = IBucketsManager.DEFAULT_ID; private boolean testMode = false; + + private boolean autoInitialize = true; } diff --git a/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsService.java b/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsService.java index 626bd0fa..fcf905de 100644 --- a/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsService.java +++ b/tw-tasks-jobs/src/main/java/com/transferwise/tasks/impl/jobs/JobsService.java @@ -36,7 +36,7 @@ public class JobsService implements IJobsService, GracefulShutdownStrategy, Init @Autowired private ITasksService tasksService; @Autowired - private JobsProperties jobsProperties; + protected JobsProperties jobsProperties; @Autowired private ApplicationContext applicationContext; @Autowired(required = false) @@ -60,7 +60,9 @@ public void afterPropertiesSet() { @Override public void applicationStarted() { - initJobs(false); + if (jobsProperties.isAutoInitialize()) { + initJobs(false); + } } @Override