@@ -0,0 +1,3198 @@
+//snippet-sourcedescription:%5BSendMessages.java demonstrates how to send messages to a queue.%5D%0A//snippet-keyword:%5BSDK for Java 2.0%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAmazon Simple Queue Service%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B2/20/2020%5D%0A//snippet-sourceauthor:%5Bscmacdon-aws%5D%0A%0A/*%0A * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at:%0A *%0A *    http://aws.amazon.com/apache2.0%0A *%0A * This file is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES%0A * OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A// snippet-start:%5Bsqs.java2.send_recieve_messages.import%5D%0Apackage com.example.sqs;%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.sqs.SqsClient;%0Aimport software.amazon.awssdk.services.sqs.model.CreateQueueRequest;%0Aimport software.amazon.awssdk.services.sqs.model.CreateQueueResponse;%0Aimport software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest;%0Aimport software.amazon.awssdk.services.sqs.model.QueueNameExistsException;%0Aimport software.amazon.awssdk.services.sqs.model.SendMessageRequest;%0A// snippet-end:%5Bsqs.java2.send_recieve_messages.import%5D%0A%0A%0Apublic class SendMessages %7B%0A%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        final String USAGE = %22%5Cn%22 +%0A                %22SendMessages - send a message%5Cn%5Cn%22 +%0A                %22Usage: SendMessages %3CqueueName%3E %3Cmessage%3E%5Cn%5Cn%22 +%0A                %22Where:%5Cn%22 +%0A                %22  queueName - the name of the queue.%5Cn%5Cn%22 +%0A                %22  message - the message to send.%5Cn%5Cn%22;%0A%0A        if (args.length %3C 2) %7B%0A            System.out.println(USAGE);%0A            System.exit(1);%0A        %7D%0A%0A        SqsClient sqsClient = SqsClient.builder()%0A                .region(Region.US_WEST_2)%0A                .build();%0A%0A        String queueName = args%5B0%5D;%0A        String message = args%5B1%5D;%0A%0A        sendMessage(sqsClient, queueName, message);%0A    %7D%0A%0A    // snippet-start:%5Bsqs.java2.send_recieve_messages.main%5D%0A    public static void sendMessage(SqsClient sqsClient, String queueName, String message) %7B%0A%0A        try %7B%0A            CreateQueueRequest request = CreateQueueRequest.builder()%0A                    .queueName(queueName)%0A                    .build();%0A            CreateQueueResponse createResult = sqsClient.createQueue(request);%0A%0A            GetQueueUrlRequest getQueueRequest = GetQueueUrlRequest.builder()%0A                .queueName(queueName)%0A                .build();%0A%0A            String queueUrl = sqsClient.getQueueUrl(getQueueRequest).queueUrl();%0A%0A            SendMessageRequest sendMsgRequest = SendMessageRequest.builder()%0A                .queueUrl(queueUrl)%0A                .messageBody(message)%0A                .delaySeconds(5)%0A                .build();%0A            sqsClient.sendMessage(sendMsgRequest);%0A%0A        %7D catch (QueueNameExistsException e) %7B%0A            throw e;%0A        %7D%0A    %7D%0A%7D%0A// snippet-end:%5Bsqs.java2.send_recieve_messages.main%5D%0A

Create SendMessages.java