Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting java.net.UnknownHostException: sqs.us-west-2.amazonaws.com when trying to create SQS Consumer #99

Open
nabihAbuabid opened this issue Apr 7, 2021 · 0 comments

Comments

@nabihAbuabid
Copy link

nabihAbuabid commented Apr 7, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant