amazon-sqs-java-messaging-lib icon indicating copy to clipboard operation
amazon-sqs-java-messaging-lib copied to clipboard

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

Open nabihAbuabid opened this issue 4 years ago • 0 comments

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

nabihAbuabid avatar Apr 07 '21 14:04 nabihAbuabid