Reputation: 998
I have created several SQS queues in the management console.
All the queues have full access permission (Allow - Everybody - All SQS Actions)
I have created necessary credentials and can connect to AWS.
Now I am trying to connect to created queues:
public static List<String> listQueues(AmazonSQS sqs) {
System.out.println("Listing all queues in your account.\n");
ListQueuesResult queueList = sqs.listQueues();
List<String> queueUrls = queueList.getQueueUrls();
for (String queueUrl : queueUrls) {
System.out.println(" QueueUrl: " + queueUrl);
}
System.out.println();
return queueUrls;
}
But nothing is displayed.
At the same time, if I create queue programatically:
public static String createQueue(String queueName, AmazonSQS sqs) {
System.out.println("Creating a new SQS queue called MyQueue.\n");
CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);
return sqs.createQueue(createQueueRequest).getQueueUrl();
}
It is listed and I can send and receive messages from it.
BUT I don't see created queue in Management Console!
What am I doing wrong?
BTW I can connect to queues created from Management Console by URL
If you are playing wih example from Amazon (like me) - keep in mind that BasicAWSCredentials contain only accessKey and secretKey, and region won't be read from credentials file.
Region is being set up "manually" for AmazonSQSClient:
public static AmazonSQS createSqsClient() {
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
AmazonSQS sqs = new AmazonSQSClient(credentials);
Region region = Region.getRegion(Regions.US_EAST_2);
sqs.setRegion(region);
return sqs;
}
Upvotes: 2
Views: 5461
Reputation: 32260
If you didn't configure the SDK to use a specific region, be it via API, via environment variables, or via $HOME/.aws/config
, it's likely that your API call to create the queue (createQueue
) is creating a new queue in the default region, us-east-1
(Virginia). Check if that's the case.
If you have multiple accounts, make sure you're using credentials to the correct account.
Upvotes: 2
Reputation: 36083
SQS queues are located in specific regions.
Upvotes: 2