0
votes

I have configured my AWS CLI tools with a config file in my home directory with my region set to eu-west-1 and can successfully list queues:

➜  ~ aws sqs list-queues
{
    "QueueUrls": [
        "https://eu-west-1.queue.amazonaws.com/9*********42/second"
    ]
}

I have the following method:

void sendMessage(String msg) {
    AmazonSQS sqs = AmazonSQSClientBuilder.standard()
            .withRegion(Regions.EU_WEST_1)
            .build();

    CreateQueueRequest createQueueRequest = new CreateQueueRequest("second");
    String myQueueURL = sqs.createQueue(createQueueRequest).getQueueUrl();

    System.out.println("A list of queues...");

    for (String qURL : sqs.listQueues().getQueueUrls()) {
        System.out.println("Found queue: " + qURL);
    }

    System.out.println("Sending msg '" + msg + "' to Q: " + myQueueURL);
    sqs.sendMessage(new SendMessageRequest(myQueueURL, msg));
    sqs.sendMessage(new SendMessageRequest("https://sqs.eu-west-1.amazonaws.com/2*********73/second", msg + " with URL"));
}

The output from running this method is:

A list of queues...
Found queue: https://sqs.eu-west-1.amazonaws.com/9*********42/second
Sending msg 'test message' to Q: https://sqs.eu-west-1.queue.amazonaws.com/9*********42/second

The URLs I get from both the AWS CLI and the SDK contain the number 9...42, but this is not what I see in the AWS console. In the console the URL contains the number 2...73.

When I added the URL from the console to my method manually (shown above) I can successfully send a message to the queue, but when I try to use the URLs given by the list-queues operation, the sqs.sendMessage() operation fails silently.

Is there a reason why these URLs could be different?

I should also add that there were two other queues ("first" and "first.fifo") which I have now deleted and no longer show in the console, but both are still listed when I use list-queues. For all these queues, the console URLs always contained the same 2...73 number and the URLs I get from the CLI and SDK always contain the same 9...42 number.

My question is - what is this number and why could it be different?

1

1 Answers

2
votes

I found the answer almost as soon as I posted the question. The number is the AWS account number and I was using an Access Key/ Secret Key combination from a different account to the one I had expected.

The reason the queues were not disappearing was that I had inadvertently created them myself by sending messages to them.

My sqs.sendMessage() calls were not silently failing, the message was appearing in queues in the other account.