diff --git a/src/main/java/com/mercateo/sqs/utils/message/handling/LongRunningMessageHandler.java b/src/main/java/com/mercateo/sqs/utils/message/handling/LongRunningMessageHandler.java index e18ae32c..e26dd194 100644 --- a/src/main/java/com/mercateo/sqs/utils/message/handling/LongRunningMessageHandler.java +++ b/src/main/java/com/mercateo/sqs/utils/message/handling/LongRunningMessageHandler.java @@ -205,5 +205,19 @@ public void shutdown() { messageProcessingExecutor.getThreadPoolExecutor().awaitTermination(10, TimeUnit.SECONDS); } } + /** + * Returns the number of elements that the {@link #messageProcessingExecutor} can accept + *
+ * This method should only be used in a single threaded environment, since it is possible that + * in a multi-threaded environment the number of free slots changes between the call to this method + * + * @return Remaining queue capacity + */ + public int getRemainingCapacity() { + return messageProcessingExecutor + .getThreadPoolExecutor() + .getQueue() + .remainingCapacity(); + } } \ No newline at end of file