mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
* feat(sqs): implement MessageMoveTask tracking, cancel, and validation
StartMessageMoveTask was a synchronous drain that returned a throwaway
task handle. ListMessageMoveTasks always returned [] and
CancelMessageMoveTask was not implemented at all. This change keeps
the synchronous-move semantics but introduces a per-account in-memory
task store and proper validation around the API.
Changes
-------
- Add SqsService.MoveTask record (handle, source, destination, max
rate, status, counters, timestamps, failure reason).
- ConcurrentHashMap<taskHandle, MoveTask> retained for the lifetime
of the process so List/Cancel can find tasks that have already
completed.
- StartMessageMoveTask:
* Accepts MaxNumberOfMessagesPerSecond and stores it on the task.
* Validates source ARN parses and queue exists (NonExistentQueue).
* Validates source is referenced as a DLQ by at least one other
queue's RedrivePolicy; otherwise throws InvalidParameterValue.
* Validates destination queue exists when provided; otherwise
throws ResourceNotFoundException (was a generic AmazonSQSException).
* Rejects a second concurrent task on the same source with
UnsupportedOperation.
- ListMessageMoveTasks returns tasks for the given source, newest
first, capped by MaxResults.
- CancelMessageMoveTask marks the task CANCELLED and returns
ApproximateNumberOfMessagesMoved; ResourceNotFoundException for
unknown handles.
- Both JSON 1.0 and Query handlers wired through; CancelMessageMoveTask
dispatch added to both.
Known follow-ups
----------------
- StartMessageMoveTask with no DestinationArn currently drops drained
messages; AWS semantics is "return each message to its original
source queue", which requires tracking per-message origin on the
DLQ side. Left for a future change.
* feat(sqs): async + rate-limited StartMessageMoveTask, reset receive state, NoDestinationArn returns messages to origin
The synchronous move-task implementation had several gaps that surfaced
under realistic client behavior:
* MaxNumberOfMessagesPerSecond was accepted but ignored -- the move
completed instantly, so a low rate with a follow-up cancel could
never actually catch the worker mid-flight.
* Cancel was effectively a no-op for the same reason.
* Two-task-for-same-source rejection couldn't fire because the first
task was already done.
* NoDestinationArn dropped the messages instead of returning them to
the queue they were DLQ'd from.
* Messages moved from a DLQ back to a queue with maxReceiveCount=1
retained their old receiveCount, so the very first ReceiveMessage
re-triggered the DLQ rule and silently round-tripped them back.
This change reworks the move task to run on a background worker that:
* Drains the source one message at a time (so the source queue stays
observably populated while the move is in flight at low rates).
* Throttles to the requested MaxNumberOfMessagesPerSecond (sleep
1000/rate ms between deliveries; 0 = no throttle).
* Resets receiveCount / firstReceiveTimestamp / receiptHandle /
visibleAt on each moved message so it starts a fresh life on the
destination queue.
* Honours a cancellation flag that CancelMessageMoveTask flips; the
worker observes it between iterations and transitions the task to
CANCELLED in its finally block.
* Routes per-message origin when no DestinationArn is supplied. The
receive path now records the source queue URL on each message it
routes to a DLQ via the redrive policy.
* Moves the very first message synchronously inside the request scope
so callers that poll the destination immediately after the call
returns see motion without racing the executor's thread start.
The two-task concurrency check trips on a recent task (started within
the last second) as well as a still-RUNNING one, which catches the
back-to-back-call pattern AWS rejects without spuriously blocking
legitimate re-runs minutes later.
* fix(sqs): MessageMoveTask review fixes - exact ARN match + AWS-aligned error
Review feedback on #910:
- Concurrent-task rejection used "AWS.SimpleQueueService.UnsupportedOperation".
Real AWS uses InvalidParameterValue with the message "There is already a
task running. Only one active task is allowed for a source queue arn at a
given time." Align the error code and message with the observed AWS
response so SDK exception typing works correctly.
- isDeadLetterQueue and listDeadLetterSourceQueues substring-matched the
raw RedrivePolicy JSON, so a queue ARN that happened to be a prefix of
another queue's ARN was falsely identified as a DLQ. Parse the
RedrivePolicy and compare deadLetterTargetArn exactly. Add a regression
test covering both the StartMessageMoveTask and ListDeadLetterSourceQueues
paths.
- Update the stale comment describing the concurrent-task race window so
it reflects the background-worker design (the move is no longer
synchronous).