-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When I run the following command on a queue of length 3, I get the top message 4 times.
awslocal sqs receive-message \
--queue-url http://localhost:4566/000000000000/ohno \
--max-number-of-messages 4
--visibility-timeout 0
Investigating further it seems to be that anytime --visibility-timeout=0 you will always receive the number of messages equal to the value of --max-number-of-messages even if your queue length is less than the value specified.
| --max-number-of-messages | # of duplicate messages |
|---|---|
| -1 | Length of queue |
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 100 | 100 |
| 9999 | 9999 |
However, if --visibility-timeout is left at the default or set to a value greater than 0 the behavior is normal.
Expected Behavior
awslocal sqs receive-message --queue-url http://localhost:4566/000000000000/ohno --max-number-of-messages=N --visibility-timeout=0
The command above should not duplicate the first message in the queue N times. It should instead return the first N messages in the queue. Additionally, it should not return more messages than the length of the queue.
How are you starting LocalStack?
With the localstack script
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)
localstack start -d
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
I can reproduce by creating a new queue and adding any number of messages.
awslocal sqs create-queue --queue-name ohno
awslocal sqs send-message --queue-url="http://localhost:4566/000000000000/ohno" --message-body "message0"
awslocal sqs send-message --queue-url="http://localhost:4566/000000000000/ohno" --message-body "message1"
awslocal sqs send-message --queue-url="http://localhost:4566/000000000000/ohno" --message-body "message2"
Receive a message with visibility timeout set to 0 and I get the message at the top of the queue duplicated.
// $ awslocal sqs receive-message --queue-url http://localhost:4566/000000000000/ohno --max-number-of-messages 3 --visibility-timeout 0
{
"Messages": [
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "MTAxZGE4ODEtNjQxMS00MmNmLWI4ODUtMjE4MDA3NWE1Y2IxIGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4Nzg0My4zNzc2MTU1",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
},
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "MmQ5ZGFlZjctNTdiMS00OGRmLTljMzgtYTQ4ZmI2NTdlMDQyIGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4Nzg0My4zNzc3MTU=",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
},
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "MzY4NzBlYzYtMjFkZS00MzFmLTlkNTYtNGQwNmJlMDM5MGMwIGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4Nzg0My4zNzc3ODU0",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
}
]
}As you can see the body of each message is identical to the first message sent even though it should be message0, message1, message2.
Additionally, if I ask for 4 messages, I get 4 messages despite the queue length only being 3.
// $ awslocal sqs receive-message --queue-url http://localhost:4566/000000000000/ohno --max-number-of-messages 4 --visibility-timeout 0
{
"Messages": [
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "ZWRlYTgzZGUtNGZmZi00ZmUzLTgwODgtYjg0MmM5YWUwNThhIGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4OTI3OS4zMTYwMTYy",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
},
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "OTEwMmEwMDEtNjlmNi00Y2Y5LTg0MWUtMzRmZDhlZDZjN2E1IGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4OTI3OS4zMTkzNTA1",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
},
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "ZGI3ZDBiYTQtOGUwZS00NDQ5LTgxNTItMzgyMTIwMThhZmY1IGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4OTI3OS4zMjI4NzM2",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
},
{
"MessageId": "09aeec37-838b-45cf-803e-2fa95b277790",
"ReceiptHandle": "MTJhZWJkOTMtNWVmZS00MTAxLWI1YmMtNjYwNjI2MTdlMzM2IGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b2hubyAwOWFlZWMzNy04MzhiLTQ1Y2YtODAzZS0yZmE5NWIyNzc3OTAgMTY3MjE4OTI3OS4zMjU3NDY4",
"MD5OfBody": "564659855f456874bfdc1b0845a5e019",
"Body": "message0"
}
]
}This holds true even if you ask for 100 messages, but it should return the only 3 I put in.
$ awslocal sqs receive-message --queue-url http://localhost:4566/000000000000/ohno --max-number-of-messages 100 --visibility-timeout 0 | jq '.Messages | length'
100Environment
- OS: Ubuntu 22.04.1 LTS
- LocalStack: 1.3.1
- Runtime version: 1.3.2.dev
- Docker image tag: latest, id: 2e7a3abeb01e, 📆 2022-12-26T23:03:21Anything else?
No response