Сервис: AmazonSQS; Код статуса: 403; Код ошибки: SignatureDoesNotMatch; SQS
Я запускаю свой простой класс на ec2 для создания или отправки сообщений на SQS. Но это дает мне Сервис: AmazonSQS; Код статуса: 403; Код ошибки: SignatureDoesNotMatch;
Я прилагаю свой код и ошибка ниже:-
private AWSSimpleQueueServiceUtil() {
try {
this.simpleQueue = "demo-Photo-Queue";
//this.sqs = (AmazonSQS) AmazonSQSClientBuilder.standard().build();
//this.sqs.setEndpoint("https://a4b.us-east-1.amazonaws.com");
this.sqs = (AmazonSQS) AmazonSQSClientBuilder.standard()
.withRegion(Regions.US_EAST_1)
.build();
} catch (Exception e) {
System.out.println("exception while creating awss3client : " + e);
}
}
public static AWSSimpleQueueServiceUtil getInstance() {
return awssqsUtil;
}
public AmazonSQS getAWSSQSClient() {
return awssqsUtil.sqs;
}
public String getQueueName() {
return awssqsUtil.simpleQueue;
}
/**
* Creates a queue in your region and returns the url of the queue
*
* @param queueName
* @return
*/
public String createQueue(String queueName) {
CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);
String queueUrl = this.sqs.createQueue(createQueueRequest).getQueueUrl();
return queueUrl;
}
/**
* returns the queueurl for for sqs queue if you pass in a name
*
* @param queueName
* @return
*/
public String getQueueUrl(String queueName) {
GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(queueName);
return this.sqs.getQueueUrl(getQueueUrlRequest).getQueueUrl();
}
/**
* send a single message to your sqs queue
*
* @param queueUrl
* @param message
*/
public void sendMessageToQueue(String queueUrl, String message) {
SendMessageResult messageResult = this.sqs.sendMessage(new SendMessageRequest(queueUrl, message));
System.out.println(messageResult.toString());
System.out.println("send successfully");
}
public static void main(String[] args) throws UnsupportedEncodingException {
//String thePath = "https://sqs.us-east-1.amazonaws.com/685308457175/demo-Photo-Queue";
String queueName = "myFisrtQueue";
queueName = URLEncoder.encode(queueName, "UTF-8");
System.out.println(queueName);
AWSSimpleQueueServiceUtil.getInstance().createQueue("queueName");
}
и вот ошибка, которую я получил:
(Служба: AmazonSQS; Код состояния: 403; Код ошибки: SignatureDoesNotMatch; Идентификатор запроса: 20311998-3b24-5878-a1d6-4d5cdc182fa2) по адресу com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHat). amazonaws.http.java:741) по адресу com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:715) по адресу com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.ham.http. $RequestExecutor.access$500(AmazonHttpClient.java:665) по адресу com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:647) по адресу com.amazonaws.http.AmazonHttplient (11) Amazon.com.amazonaws.services.SQS) по адресу com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1480) по адресу com.SQSDemojava.demo.AWSSimpleQueueServiceUtil.sendMessageToQueue(AWSSimpleQueue.WeueSerueUviceStilue.WueSuerServiceStil.exe) Java:120) myFisrtQueue