Comment appeler AmazonSQSAsync.
AmazonSQSAsync sqs = SQS.getAsyncClient();
try {
CreateQueueResult queue =
sqs.createQueue(
new CreateQueueRequest().withQueueName(QUEUE_NAME));
HashMap<String, MessageAttributeValue> map =
new HashMap<String, MessageAttributeValue>();
map.put(
"foo",
new MessageAttributeValue().withDataType("String").withStringValue(
"aaa"));
Future<SendMessageResult> result =
sqs.sendMessageAsync(
new SendMessageRequest(queue.getQueueUrl(), "Message")
.withMessageAttributes(map));
while (!result.isDone()) {
Thread.sleep(10);
}
} catch (Exception e) {
logger.error(e);
} finally {
sqs.shutdown();
}
Future
Recommended Posts