3
votes

When using AWS CLI version aws-cli/1.15.50, Python/3.7.0, Darwin/16.7.0, botocore/1.10.49, the command

aws sqs list-queues

returns a list of the format

https://us-west-2.queue.amazonaws.com/<a number>/<queue-name>

When I call the equivalent from the Java SDK (SDK version 1.11.344 called from Scala version 2.12.6), I get a list of the format

https://sqs.us-west-2.amazonaws.com/<a number>/<queue-name>

PLEASE NOTE: the number is the same in both URLs as are the corresponding queue names.

The differences are:

  1. The CLI begins with the region (us-west-2) while the SDK begins with sqs.
  2. After the region, the CLI's domain name is .queue.amazonaws.com but the JDK has just .amazonaws.com. (The SDK does not have the token queue..)

I get the same results when using get-queue-url and getQueueUrl (either overload in the SDK).

Messages sent using aws sqs send-message with the URL returned by the CLI are not received by the Scala program using the URL returned by the AWS Java SDK.

What am I doing wrong?

1
when you push the messages using CLI and Java SDK, do they both show up in the same queue?Asdfg
Both addresses seem to resolve to the same IP. When you use aws sqs send-message, can you see the message in the SQS management console? If so, then the problem lies with message retrieval.John Rotenstein

1 Answers

2
votes

The AWS SQS Queue url is provided in the following format (see this link):

https://{REGION_ENDPOINT}/queue.|api-domain|/{YOUR_ACCOUNT_NUMBER}/{YOUR_QUEUE_NAME}

If you had given us the code you used to retrieve the urls in java, we could have seen what the real root cause is. What you have got as the response for your JAVA SDK call is an AWS Endpoint. (see this link).

To reduce data latency in your applications, most Amazon Web Services offer a regional endpoint to make your requests. An endpoint is a URL that is the entry point for a web service. For example, https://dynamodb.us-west-2.amazonaws.com is an entry point for the Amazon DynamoDB service.

You can try out to retrieve the SQS URL using the JAVA SDK using the following code. This is for a single Queue URL given the Queue name. (See this doc)

AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
String queue_url = sqs.getQueueUrl(QUEUE_NAME).getQueueUrl();

You can also use the listQueues method to retrieve the Queue URL list, as given in this doc.

If you are still getting the SQS Endpoint...

If you keep on getting the SQS Queue URL Endpoint, instead of the SQS actual Queue URL, you can use the endpoint to access and manipulate the queue as you require. Have a look at this example written in Java, which will help you understand how to use the endpoint and create a workaround with it.