mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(sqs): FIFO ReceiveMessage returns multiple messages per group per call (#785)
* fix(sqs): FIFO ReceiveMessage returns multiple messages per group per call
A FIFO ReceiveMessage call may legitimately return multiple messages
from the same MessageGroupId, in insertion order, up to
MaxNumberOfMessages. Floci was capping each call at one message per
group, which in practice limited tests to 1-2 messages regardless of
how many were queued and broke ordering tests for high-throughput
("fair") FIFO queues distributing across groups.
The cross-call group lock is unchanged: a group with an in-flight
message from a previous call is still blocked until that message is
deleted or its visibility expires. Only the within-call constraint
was wrong.
Existing tests that asserted the buggy "one per group per call"
contract have been updated to assert AWS-correct behavior.
Refs #768.
* test(sqs): address PR review feedback on FIFO multi-message tests
- Loosen cross-group ordering assertions in FIFO receive tests:
FIFO only guarantees ordering within a MessageGroupId, not across
groups, so assert group1 messages are in-order relative to each
other and group2 message is present without fixing its position.
- Rename fifoQueue_groupLockBlocksAcrossCallsButNotWithin to
fifoQueueGroupLockBlocksAcrossCallsButNotWithin to match the
test class's lowerCamelCase convention.
* test(sqs): add FIFO partial-drain unlock and compat coverage
Address review feedback on PR #785:
- SqsServiceTest: add fifoQueueGroupUnlocksAfterAllInFlightMessagesDeleted
covering the most common consumer pattern — drain less than a full
group in one call, delete the in-flight messages, then receive the
remainder. Verifies the group lock unlocks once all in-flight
messages from that group are deleted.
- sdk-test-java SqsTest: add fifoReceiveReturnsMultipleMessagesFromSameGroupInOneCall
as the first FIFO test in the compatibility suite. Sends 3 messages
to a single MessageGroupId and asserts a single ReceiveMessage with
MaxNumberOfMessages=10 returns all three — closes the gap noted in
the review and provides a regression guard against real AWS.
This commit is contained in:
1 parent
ffd7779c5c
commit
3bf16e3fb9
4 files changed
+115
-27
No files matched your search
@@ -343,6 +343,45 @@ class SqsTest {
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
void fifoReceiveReturnsMultipleMessagesFromSameGroupInOneCall() {
|
||||
// Regression test for https://github.com/floci-io/floci/issues/777
|
||||
// AWS FIFO: a single ReceiveMessage may return multiple messages from
|
||||
// the same MessageGroupId, up to MaxNumberOfMessages.
|
||||
String fifoQueueName = "sdk-test-fifo-multi-" + System.currentTimeMillis() + ".fifo";
|
||||
String fifoQueueUrl = sqs.createQueue(CreateQueueRequest.builder()
|
||||
.queueName(fifoQueueName)
|
||||
.attributes(Map.of(QueueAttributeName.FIFO_QUEUE, "true"))
|
||||
.build()).queueUrl();
|
||||
try {
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
sqs.sendMessage(SendMessageRequest.builder()
|
||||
.queueUrl(fifoQueueUrl)
|
||||
.messageBody("msg" + i)
|
||||
.messageGroupId("g1")
|
||||
.messageDeduplicationId("d" + i)
|
||||
.build());
|
||||
}
|
||||
|
||||
ReceiveMessageResponse rcv = sqs.receiveMessage(ReceiveMessageRequest.builder()
|
||||
.queueUrl(fifoQueueUrl)
|
||||
.maxNumberOfMessages(10)
|
||||
.build());
|
||||
|
||||
assertThat(rcv.messages())
|
||||
.as("FIFO ReceiveMessage must return all 3 messages from group g1 in one call")
|
||||
.hasSize(3);
|
||||
assertThat(rcv.messages().get(0).body()).isEqualTo("msg1");
|
||||
assertThat(rcv.messages().get(1).body()).isEqualTo("msg2");
|
||||
assertThat(rcv.messages().get(2).body()).isEqualTo("msg3");
|
||||
} finally {
|
||||
try {
|
||||
sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(fifoQueueUrl).build());
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
void deleteQueue() {
|
||||
sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(queueUrl).build());
|
||||
if (dlqUrl != null) {
|
||||
|
||||
Reference in new issue
Block a user