diff --git a/merlin-worker/src/main/java/gov/nasa/jpl/aerie/merlin/worker/MerlinWorkerAppDriver.java b/merlin-worker/src/main/java/gov/nasa/jpl/aerie/merlin/worker/MerlinWorkerAppDriver.java index 777b0c9e2f..0aee80eb7a 100644 --- a/merlin-worker/src/main/java/gov/nasa/jpl/aerie/merlin/worker/MerlinWorkerAppDriver.java +++ b/merlin-worker/src/main/java/gov/nasa/jpl/aerie/merlin/worker/MerlinWorkerAppDriver.java @@ -21,6 +21,7 @@ import java.time.Instant; import java.util.Optional; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; public final class MerlinWorkerAppDriver { public static void main(String[] args) throws InterruptedException { @@ -67,8 +68,9 @@ public static void main(String[] args) throws InterruptedException { try (final var app = Javalin.create().start(8080)) { app.get("/health", ctx -> ctx.status(200)); - while (true) { - final var notification = notificationQueue.take(); + while (listenThread.isAlive()) { + final var notification = notificationQueue.poll(1, TimeUnit.MINUTES); + if(notification == null) continue; final var planId = new PlanId(notification.planId()); final var datasetId = notification.datasetId(); diff --git a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java index 5f504fb6db..7bc698ae0e 100644 --- a/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java +++ b/scheduler-worker/src/main/java/gov/nasa/jpl/aerie/scheduler/worker/SchedulerWorkerAppDriver.java @@ -5,6 +5,8 @@ import java.nio.file.Path; import java.util.Optional; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import gov.nasa.jpl.aerie.scheduler.server.ResultsProtocol; @@ -76,8 +78,9 @@ public static void main(String[] args) throws Exception { try(final var app = Javalin.create().start(8080)) { app.get("/health", ctx -> ctx.status(200)); - while (true) { - final var notification = notificationQueue.take(); + while (listenThread.isAlive()) { + final var notification = notificationQueue.poll(1, TimeUnit.MINUTES); + if (notification == null) continue; final var specificationRevision = notification.specificationRevision(); final var specificationId = new SpecificationId(notification.specificationId());