From 472613e534325a2bfaa89f950830a301d8caff38 Mon Sep 17 00:00:00 2001 From: David Gauldie Date: Tue, 5 Nov 2024 14:57:23 -0500 Subject: [PATCH] set prefetch count to 1 (#5398) --- .../terarium/hmiserver/service/tasks/TaskService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/tasks/TaskService.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/tasks/TaskService.java index eb7c216828..6811493de5 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/tasks/TaskService.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/service/tasks/TaskService.java @@ -57,7 +57,7 @@ @RequiredArgsConstructor public class TaskService { - public static enum TaskMode { + public enum TaskMode { @JsonAlias("sync") SYNC("sync"), @JsonAlias("async") @@ -389,7 +389,7 @@ private void initResponseConsumers() { // unique queue to ensure the local server also gets it. final String queueName = !isRunningLocalProfile() ? TASK_RUNNER_RESPONSE_QUEUE - : TASK_RUNNER_RESPONSE_QUEUE + "-local-" + UUID.randomUUID().toString(); + : TASK_RUNNER_RESPONSE_QUEUE + "-local-" + UUID.randomUUID(); // Declare a direct exchange final DirectExchange exchange = new DirectExchange(TASK_RUNNER_RESPONSE_EXCHANGE, IS_DURABLE_QUEUES, false); @@ -407,6 +407,7 @@ private void initResponseConsumers() { rabbitAdmin.getRabbitTemplate().getConnectionFactory() ); + container.setPrefetchCount(1); container.setQueueNames(queueName); container.setMessageListener(message -> { onTaskResponseOneInstanceReceives(message); @@ -673,7 +674,7 @@ public TaskFuture runTaskAsync(final TaskRequest r) throws JsonProcessingExcepti // now send request final String requestQueue = String.format("%s-%s", TASK_RUNNER_REQUEST_QUEUE, req.getType().toString()); - log.info("Readying task: {} with SHA: {} to send on queue: {}", req.getId(), hash, req.getType().toString()); + log.info("Readying task: {} with SHA: {} to send on queue: {}", req.getId(), hash, req.getType()); // ensure the request queue exists declareQueue(req.getType(), requestQueue);