Search in sources :

Example 6 with SqsClient

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();
}
Also used : SqsClient(software.amazon.awssdk.services.sqs.SqsClient)

Example 7 with SqsClient

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();
}
Also used : SqsClient(software.amazon.awssdk.services.sqs.SqsClient)

Example 8 with SqsClient

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();
}
Also used : SqsClient(software.amazon.awssdk.services.sqs.SqsClient) Date(java.util.Date)

Example 9 with SqsClient

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();
}
Also used : SqsClient(software.amazon.awssdk.services.sqs.SqsClient)

Example 10 with SqsClient

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();
}
Also used : SqsClient(software.amazon.awssdk.services.sqs.SqsClient)

Aggregations

SqsClient (software.amazon.awssdk.services.sqs.SqsClient)18 Region (software.amazon.awssdk.regions.Region)2 RekognitionClient (software.amazon.awssdk.services.rekognition.RekognitionClient)2 NotificationChannel (software.amazon.awssdk.services.rekognition.model.NotificationChannel)2 Message (software.amazon.awssdk.services.sqs.model.Message)2 ReceiveMessageRequest (software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest)2 Date (java.util.Date)1 CreateQueueRequest (software.amazon.awssdk.services.sqs.model.CreateQueueRequest)1 CreateQueueResponse (software.amazon.awssdk.services.sqs.model.CreateQueueResponse)1 GetQueueUrlRequest (software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest)1 PurgeQueueRequest (software.amazon.awssdk.services.sqs.model.PurgeQueueRequest)1 QueueNameExistsException (software.amazon.awssdk.services.sqs.model.QueueNameExistsException)1 SendMessageBatchRequest (software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest)1 SendMessageRequest (software.amazon.awssdk.services.sqs.model.SendMessageRequest)1