use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class DeadLetterQueues method main.
public static void main(String[] args) {
SqsClient sqs = SqsClient.builder().region(Region.US_WEST_2).build();
setDeadLetterQueue(sqs);
sqs.close();
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class LongPolling method main.
public static void main(String[] args) {
// Create a SqsClient object
SqsClient sqsClient = SqsClient.builder().region(Region.US_WEST_2).build();
setLongPoll(sqsClient);
sqsClient.close();
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class VisibilityTimeout method main.
// snippet-start:[sqs.java2.visibility_timeout.main]
public static void main(String[] args) {
final String queueName = "testQueue" + new Date().getTime();
SqsClient sqs = SqsClient.builder().region(Region.US_WEST_2).build();
// First, create a queue (unless it exists already)
CreateQueueRequest createRequest = CreateQueueRequest.builder().queueName(queueName).build();
try {
sqs.createQueue(createRequest);
} catch (SqsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
GetQueueUrlRequest getRequest = GetQueueUrlRequest.builder().queueName(queueName).build();
// Send some messages to the queue
for (int i = 0; i < 20; i++) {
SendMessageRequest sendRequest = SendMessageRequest.builder().queueUrl(queueName).messageBody("This is message " + i).build();
sqs.sendMessage(sendRequest);
}
// change visibility timeout (single)
changeMessageVisibilitySingle(sqs, queueName, 3600);
// change visibility timeout (multiple)
changeMessageVisibilityMultiple(sqs, queueName, 2000);
sqs.close();
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class ListQueueTags method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <queueName>\n\n" + "Where:\n" + " queueName - the name of the queue.\n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String queueName = args[0];
SqsClient sqsClient = SqsClient.builder().region(Region.US_WEST_2).build();
listTags(sqsClient, queueName);
sqsClient.close();
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class RemoveQueueTag method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <queueName> <tagName>\n\n" + "Where:\n" + " queueName - the name of the queue to which tags are applied.\n\n" + " tagName - the name of the tag to remove.";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String queueName = args[0];
String tagName = args[1];
SqsClient sqsClient = SqsClient.builder().region(Region.US_WEST_2).build();
removeTag(sqsClient, queueName, tagName);
sqsClient.close();
}
Aggregations