softwaremill / elasticmq

In-memory message queue with an Amazon SQS-compatible interface. Runs stand-alone or embedded.
https://softwaremill.com/open-source/
Apache License 2.0
2.55k stars 196 forks source link

Creating a queue in a specific region doesn't reflect in the queue's messages #162

Closed christian-eriksson closed 5 years ago

christian-eriksson commented 5 years ago

When I create a SQS queue like so:

aws sqs --endpoint-url http://<host-ip/name>:9324 create-queue \
    --queue-name TestQueue --region eu-central-1

The specified --region doesn't seem to reflect the region represented by the messages received from the queue.

If I send a message to the either through the JavaScript aws-sdk or command line:

aws sqs --endpoint-url http://<host-ip/name>:9324 send-message \
    --queue-url http://<host-ip/name>:9324/queue/TestQueue  \
    --message-body "Some message"

The message received from the queue would look something like:

{
    "Records": [
        {
            "messageId": "6e9e6c35-df6a-4362-ae98-6d5f7f0e8a6a",
            "receiptHandle": "6e9e6c35-df6a-4362-ae98-6d5f7f0e8a6a#fa8da3e0-447a-4163...",
            "body": "Some message",
            "attributes": {
                "SentTimestamp": "1549118769614",
                "ApproximateReceiveCount": "1",
                "ApproximateFirstReceiveTimestamp": "1549118769618",
                "SenderId": "127.0.0.1",
                "MessageDeduplicationId": "",
                "MessageGroupId": ""
            },
            "md5OfBody": "2ae04ba2776203c2479661da8aa4417c",
            "eventSource": "aws:sqs",
            "eventSourceARN": {
                "Fn::GetAtt": [
                    "TestQueue",
                    "Arn"
                ]
            },
            "awsRegion": "us-west-2"
        }
    ]
}

But I would have expected the awsRegion attribute to say eu-central-1 instead of us-west-2.

I'm not sure if this as any practical implications or if it's just cosmetics, because I seem to be able to send messages even if the region specified in the aws-sdk when sending messages is not the one specified for the queue, at creation, nor the one specified for the queue in serverless.yml.

AWS.config.update({region: 'eu-north-1'}); // not the region specified for queue
var sqs = new AWS.SQS({
  apiVersion: '2012-11-05',
  endpoint: 'http://sqs:9324'
});
const params = {
      MessageBody: "Some Message"
      QueueUrl: "http://<host-ip/name>:9324/queue/TestQueue"
    };
await sqs.sendMessage(params).promise(); // this still works

I've created a small example where the queue is created in eu-central-1, but the messages are still reported as being from us-west-2.

Opalo commented 5 years ago

@SirSkorpan, I'm trying to reproduce the problem but I'm unable to do so. I've tried to create a queue, send a message and finally receive it on both aws sqs instance and using elasticmq. Here are the "logs":

Could you please clarify how it can be reproduced?

Opalo commented 5 years ago

I'm closing this issue since I've received no reply.