awslabs / awslabs/amazon-sqs-java-messaging-lib
Getting java.net.UnknownHostException: sqs.us-west-2.amazonaws.com when trying to create SQS Consumer
- Dominant language
- Java
- Stars
- 183
- Forks
- 150
- PR merge metrics
- No merged PRs in 30d
Description
I have a code that creates consumer for polling. I use the lates amazon-sqs-java-messaging-lib (1.0.8). below is the consumer creator code
```
try {
// Create the connection factory based on the config
// Create a new connection factory with all defaults (credentials and region) set automatically
SQSConnectionFactory connectionFactory = new SQSConnectionFactory(
new ProviderConfiguration(),
AmazonSQSClientBuilder.standard().withRegion(region).build());
// Create the connection
SQSConnection connection = connectionFactory.createConnection();
// Create the session
session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
consumer = session
.createConsumer(((SQSSession) session).createQueue(endpoint, "myAcctOwnerID"));
// Start receiving incoming messages.
connection.start();
isIntialized = true;
logger.info(String
.format("SQS Consumer created and initialized for endpoint: %s, Region:%s", endpoint,
region));
} catch (Exception e) {
logger.error(String
.format("Error creating sqs consumer for endpoint: %s, Region:%s", endpoint, region), e);
isIntialized = false;
}
```
When I start the client for message receiving I get the exception in the attached file.
What I'm doing wrong? I use the code for the producer and it works fine.
I pass the endpoint as the name of the Queue
[AWS_SQS_STACKTRACE.txt](https://github.com/awslabs/amazon-sqs-java-messaging-lib/files/6272331/AWS_SQS_STACKTRACE.txt)
Contributor guide
Assessment
This issue has not been assessed yet.