0
votes

I am not able to send message on an SQS queue through AWS Java SDK. Here is code that I am using:

    final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
    try {
        String queueUrl = "My sqs queue url"
        sqs.sendMessage(new SendMessageRequest(queueUrl, "This is my message text."));
    } catch (final AmazonServiceException ase) {
        //log error message here                
    } catch (final AmazonClientException ace) {
        //log error message here
    }

This snippet throws AmazonServiceException with message: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details

In SDK documentation, there is nothing mentioned about how to sign the request. Also, For authentication, I have exported environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY containing AWS access key and secret values.

I picked this sample code from AWS documentation

Can anyone help me about how to fix this?

1
try to specify the region as well AWS_DEFAULT_REGIONgusto2
@gusto2, I just tried specifying the region, but it did not help.Manish
Which version of the SDK do you use? Are you sure the credentials passed to the SQS client are those you expect (i.e they are not overwritten somewhere)? In which region is your SQS queue? (the default region is us-west-2)Alexandre Dupriez

1 Answers

0
votes

There is something wrong with my credentials. Things started working when I tried creating a new account and used fresh pair of key and secret. I will ask my AWS account manager of my organization to regenerate the key-secrete pair. Thanks @gusto2 and @AlexandreDupriez.