mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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:
1 parent
972faafe13
commit
db21bc9ec6
2 files changed
+30
-1
No files matched your search
@@ -288,4 +288,27 @@ class SqsServiceTest {
|
||||
assertThrows(AwsException.class, () ->
|
||||
sqsService.sendMessage(queue.getQueueUrl(), "msg", 0, "group1", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void receiveMessageUsesQueueVisibilityTimeoutWhenNotSpecified() {
|
||||
// Create queue with a short visibility timeout (1 second)
|
||||
Queue queue = sqsService.createQueue("short-vt-queue",
|
||||
Map.of("VisibilityTimeout", "1"));
|
||||
sqsService.sendMessage(queue.getQueueUrl(), "test-msg", 0);
|
||||
|
||||
// Receive without specifying visibility timeout (-1 means "use queue default")
|
||||
List<Message> first = sqsService.receiveMessage(queue.getQueueUrl(), 1, -1, 0);
|
||||
assertEquals(1, first.size());
|
||||
|
||||
// Message should be invisible immediately after receive
|
||||
List<Message> second = sqsService.receiveMessage(queue.getQueueUrl(), 1, -1, 0);
|
||||
assertTrue(second.isEmpty());
|
||||
|
||||
// Wait for the queue's visibility timeout (1s) to expire, not the global default (30s)
|
||||
try { Thread.sleep(1100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
|
||||
|
||||
// Message should now be visible again
|
||||
List<Message> third = sqsService.receiveMessage(queue.getQueueUrl(), 1, -1, 0);
|
||||
assertEquals(1, third.size(), "Message should become visible after queue's VisibilityTimeout (1s), not global default (30s)");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user