fix(sqs): use queue-level VisibilityTimeout as fallback in ReceiveMessage (#413)

When ReceiveMessage does not specify a VisibilityTimeout parameter,
doReceiveMessage falls back to the global default (30s) instead of the
queue's own VisibilityTimeout attribute. This causes messages to stay
invisible far longer than expected, which in turn breaks DLQ redrive
for queues configured with a short visibility timeout — the message
never becomes visible within a reasonable window for the receive-count
check to trigger.

Read the queue's VisibilityTimeout attribute as the intermediate
fallback before using the global default.
This commit is contained in:
Mikołaj Kłosowski authored and GitHub committed 2026-04-13 16:12:22 -05:00
1 parent 972faafe13
commit db21bc9ec6
2 files changed
+30 -1

No files matched your search

@@ -479,7 +479,13 @@ public class SqsService {
return Collections.emptyList();
}
int effectiveTimeout = visibilityTimeout >= 0 ? visibilityTimeout : defaultVisibilityTimeout;
int effectiveTimeout;
if (visibilityTimeout >= 0) {
effectiveTimeout = visibilityTimeout;
} else {
String queueVt = queue.getAttributes().get("VisibilityTimeout");
effectiveTimeout = queueVt != null ? Integer.parseInt(queueVt) : defaultVisibilityTimeout;
}
RedrivePolicy rp = getOrParseRedrivePolicy(queue, storageKey);
int maxReceiveCount = rp != null ? rp.maxReceiveCount() : -1;