Example usage for com.amazonaws.services.sqs AmazonSQSClient AmazonSQSClient

List of usage examples for com.amazonaws.services.sqs AmazonSQSClient AmazonSQSClient

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs AmazonSQSClient AmazonSQSClient.

Prototype

AmazonSQSClient(AwsSyncClientParams clientParams) 

Source Link

Document

Constructs a new client to invoke service methods on Amazon SQS using the specified parameters.

Usage

From source file:com.pocketdealhunter.HotDealsMessagesUtil.java

License:Open Source License

public HotDealsMessagesUtil() {
    AWSCredentials credentials = new BasicAWSCredentials(Constants.ACCESS_KEY_ID, Constants.SECRET_KEY);
    Region region = Region.getRegion(Regions.US_WEST_2);

    this.snsClient = new AmazonSNSClient(credentials);
    this.snsClient.setRegion(region);

    this.sqsClient = new AmazonSQSClient(credentials);
    this.sqsClient.setRegion(region);

    // Find the Topic for this App or create one.
    this.topicARN = this.findTopicArn();
    if (topicARN == null) {
        this.topicARN = this.createTopic();
    }/*from ww w.  j  a va2 s .c  om*/

    // Find the Queue for this App or create one.
    this.queueUrl = this.findQueueUrl();
    if (this.queueUrl == null) {
        this.queueUrl = this.createQueue();

        // Allow time for the queue to be created.
        try {
            Thread.sleep(4 * 1000);
        } catch (Exception exception) {
        }

        this.subscribeQueue();
    }
}

From source file:com.rodosaenz.samples.aws.sqs.AwsSqsSimpleExample.java

License:Open Source License

public static void main(String[] args) throws Exception {

    /*//from w ww .j  a v a 2s.  co  m
     * The ProfileCredentialsProvider will return your [default]
     * credential profile by reading from the credentials file located at
     * (~/.aws/credentials).
     */
    AWSCredentials credentials = null;
    try {
        credentials = new ProfileCredentialsProvider().getCredentials();
    } catch (Exception e) {
        throw new AmazonClientException("Cannot load the credentials from the credential profiles file. "
                + "Please make sure that your credentials file is at the correct "
                + "location (~/.aws/credentials), and is in valid format.", e);
    }

    AmazonSQS sqs = new AmazonSQSClient(credentials);
    Region usWest2 = Region.getRegion(Regions.US_EAST_1);
    sqs.setRegion(usWest2);

    System.out.println("===========================================");
    System.out.println("Getting Started with Amazon SQS");
    System.out.println("===========================================\n");

    String queue_name = "com-rodosaenz-examples-aws-sqs";

    try {
        // Create a queue
        System.out.println("Creating a new SQS queue called " + queue_name + ".\n");
        CreateQueueRequest createQueueRequest = new CreateQueueRequest(queue_name);
        String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();

        // List queues
        System.out.println("Listing all queues in your account.\n");
        for (String queueUrl : sqs.listQueues().getQueueUrls()) {
            System.out.println("  QueueUrl: " + queueUrl);
        }
        System.out.println();

        // Send a message
        System.out.println("Sending a message to " + queue_name + ".\n");
        sqs.sendMessage(new SendMessageRequest(myQueueUrl, "This is my message text."));
        // Receive messages
        System.out.println("Receiving messages from MyQueue.\n");
        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
        receiveMessageRequest.setMaxNumberOfMessages(1);
        List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
        for (Message message : messages) {
            System.out.println("  Message");
            System.out.println("    MessageId:     " + message.getMessageId());
            System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
            System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
            System.out.println("    Body:          " + message.getBody());
            for (Entry<String, String> entry : message.getAttributes().entrySet()) {
                System.out.println("  Attribute");
                System.out.println("    Name:  " + entry.getKey());
                System.out.println("    Value: " + entry.getValue());
            }
        }

        System.out.println();

        // Delete a message
        System.out.println("Deleting a message.\n");
        String messageReceiptHandle = messages.get(0).getReceiptHandle();
        sqs.deleteMessage(new DeleteMessageRequest(myQueueUrl, messageReceiptHandle));

        //Get attributes
        GetQueueAttributesRequest request = new GetQueueAttributesRequest(myQueueUrl).withAttributeNames("All");
        final Map<String, String> attributes = sqs.getQueueAttributes(request).getAttributes();

        System.out.println("  Policy: " + attributes.get("Policy"));
        System.out.println("  MessageRetentionPeriod: " + attributes.get("MessageRetentionPeriod"));
        System.out.println("  MaximumMessageSize: " + attributes.get("MaximumMessageSize"));
        System.out.println("  CreatedTimestamp: " + attributes.get("CreatedTimestamp"));
        System.out.println("  VisibilityTimeout: " + attributes.get("VisibilityTimeout"));
        System.out.println("  QueueArn: " + attributes.get("QueueArn"));
        System.out.println("  ApproximateNumberOfMessages: " + attributes.get("ApproximateNumberOfMessages"));
        System.out.println("  ApproximateNumberOfMessagesNotVisible: "
                + attributes.get("ApproximateNumberOfMessagesNotVisible"));
        System.out.println("  DelaySeconds: " + attributes.get("DelaySeconds"));

        // Delete a queue
        System.out.println("Deleting the test queue.\n");
        sqs.deleteQueue(new DeleteQueueRequest(myQueueUrl));

    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SQS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with SQS, such as not "
                + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}

From source file:com.sag.tn.storm.stormmaven.main.Main.java

License:Open Source License

public static void main(String[] args) {

    AWSCredentials credentials = null;//from   w w w.j  av  a2 s  .  c o m
    try {
        credentials = new EnvironmentVariableCredentialsProvider().getCredentials();
    } catch (Exception e) {
        throw new AmazonClientException("Cannot load the credentials from the credential profiles file. "
                + "Please make sure that your credentials file is at the correct "
                + "location (~/.aws/credentials), and is in valid format.", e);
    }

    AmazonSQS sqs = new AmazonSQSClient(credentials);

    sqs.purgeQueue(new PurgeQueueRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue"));

    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>10</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>11</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>12</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>13</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>14</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>15</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>16</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>17</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>18</Value></PurchaseOrderRequest>"));
    sqs.sendMessage(new SendMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue",
            "<PurchaseOrderRequest><Value>19</Value></PurchaseOrderRequest>"));

    System.out.println("sent");
    /*
    // Receive messages
    System.out.println("Receiving messages from MyQueue.\n");
    ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue");
            
    for(int i = 0; i < 7; i++) {
            
       List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
               
       System.out.println(messages.size());
               
       for (Message message : messages) {
       System.out.println("  Message");
       System.out.println("    MessageId:     " + message.getMessageId());
       System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
       System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
       System.out.println("    Body:          " + message.getBody());
       for (Entry<String, String> entry : message.getAttributes().entrySet()) {
           System.out.println("  Attribute");
           System.out.println("    Name:  " + entry.getKey());
           System.out.println("    Value: " + entry.getValue());
       }
               
       sqs.deleteMessage(new DeleteMessageRequest("https://sqs.us-west-2.amazonaws.com/238337343154/b2baaSTestQueue", message.getReceiptHandle()));
       }
    }*/

    /*MongoCredential credential = MongoCredential.createCredential("gergreg", "45345453", "34534fgalkej".toCharArray());
    MongoClient mClient = new MongoClient(new ServerAddress("rgergerg", 33760), Arrays.asList(credential));
    MongoDatabase db = mClient.getDatabase("5235235235");
    MongoCollection<Document> coll = db.getCollection("35235325235");*/

    /*MongoCursor<Document> cursor = coll.find(eq("rootTag", "IDataXMLCoder")).iterator();
    while(cursor.hasNext()) {
        Document document = cursor.next();
       System.out.println((String)document.get("docTypeId"));
       break;
    }*/

    /*coll.updateOne(eq("docTypeId", "f0cf1e95-9406-44dc-930f-8de9aae8ccaf123"),
        new Document("$inc", new Document("execs", 100)));
            
    System.out.println("updated...");
            
    mClient.close();*/

}

From source file:com.sjsu.cmpe281.team06.NovaMiaas.SimpleQueueServiceSample.java

License:Open Source License

public static void main(String[] args) throws Exception {
    /*/*w ww .ja va2s . c  om*/
     * This credentials provider implementation loads your AWS credentials
     * from a properties file at the root of your classpath.
     *
     * Important: Be sure to fill in your AWS access credentials in the
     *            AwsCredentials.properties file before you try to run this
     *            sample.
     * http://aws.amazon.com/security-credentials
     */
    AmazonSQS sqs = new AmazonSQSClient(new ClasspathPropertiesFileCredentialsProvider());
    Region usWest1 = Region.getRegion(Regions.US_WEST_1);
    sqs.setRegion(usWest1);

    System.out.println("===========================================");
    System.out.println("Getting Started with Amazon SQS");
    System.out.println("===========================================\n");

    try {
        // Create a queue
        System.out.println("Creating a new SQS queue called MyQueue.\n");
        CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyQueue");
        String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();

        // List queues
        System.out.println("Listing all queues in your account.\n");
        for (String queueUrl : sqs.listQueues().getQueueUrls()) {
            System.out.println("  QueueUrl: " + queueUrl);
        }
        System.out.println();

        // Send a message
        System.out.println("Sending a message to MyQueue.\n");
        sqs.sendMessage(new SendMessageRequest(myQueueUrl, "This is my new message text."));

        // Receive messages
        System.out.println("Receiving messages from MyQueue.\n");
        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
        List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
        for (Message message : messages) {
            System.out.println("  Message");
            System.out.println("    MessageId:     " + message.getMessageId());
            System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
            System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
            System.out.println("    Body:          " + message.getBody());
            for (Entry<String, String> entry : message.getAttributes().entrySet()) {
                System.out.println("  Attribute");
                System.out.println("    Name:  " + entry.getKey());
                System.out.println("    Value: " + entry.getValue());
            }
        }
        System.out.println();

        // Delete a message
        System.out.println("Deleting a message.\n");
        String messageRecieptHandle = messages.get(0).getReceiptHandle();
        sqs.deleteMessage(new DeleteMessageRequest(myQueueUrl, messageRecieptHandle));

        // Delete a queue
        System.out.println("Deleting the test queue.\n");
        sqs.deleteQueue(new DeleteQueueRequest(myQueueUrl));

    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SQS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with SQS, such as not "
                + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}

From source file:com.springboot.jms.AWSJmsSend.java

License:Open Source License

public static void testAWSQueue() throws Exception {

    AmazonSQS sqs = new AmazonSQSClient(new BasicAWSCredentials("", ""));
    Region usWest2 = Region.getRegion(Regions.US_EAST_1);
    sqs.setRegion(usWest2);/*  www.ja v a  2  s  .co  m*/

    System.out.println("===========================================");
    System.out.println("Getting Started with Amazon SQS");
    System.out.println("===========================================\n");

    try {

        String myQueueUrl = "https://sqs.us-east-1.amazonaws.com/918558451804/PetQueue";

        // Send a message
        System.out.println("Sending a message to MyQueue.\n");
        for (int i = 1; i <= 11; i++) {
            sqs.sendMessage(new SendMessageRequest(myQueueUrl, "This is my message number " + i));
            Thread.sleep(1000);
        }

    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SQS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with SQS, such as not "
                + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}

From source file:com.springboot.jms.AWSJmsSendAndReceive.java

License:Open Source License

public static void testAWSQueue() throws Exception {

    /*/*w  ww.j  ava 2  s .  c om*/
     * The ProfileCredentialsProvider will return your [default]
     * credential profile by reading from the credentials file located at
     * (~/.aws/credentials).
     */
    /*        AWSCredentials credentials = null;
            try {
    credentials = new ProfileCredentialsProvider().getCredentials();
            } catch (Exception e) {
    throw new AmazonClientException(
            "Cannot load the credentials from the credential profiles file. " +
            "Please make sure that your credentials file is at the correct " +
            "location (~/.aws/credentials), and is in valid format.",
            e);
            }
            
            AmazonSQS sqs = new AmazonSQSClient(credentials);*/

    AmazonSQS sqs = new AmazonSQSClient(new BasicAWSCredentials("", ""));
    Region usWest2 = Region.getRegion(Regions.US_EAST_1);
    sqs.setRegion(usWest2);

    System.out.println("===========================================");
    System.out.println("Getting Started with Amazon SQS");
    System.out.println("===========================================\n");

    try {
        /*            // Create a queue
                    System.out.println("Creating a new SQS queue called MyQueue.\n");
                    CreateQueueRequest createQueueRequest = new CreateQueueRequest("PetQueue");
                    String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();*/

        String myQueueUrl = "https://sqs.us-east-1.amazonaws.com/918558451804/PetQueue";
        // List queues
        System.out.println("Listing all queues in your account.\n");
        for (String queueUrl : sqs.listQueues().getQueueUrls()) {
            System.out.println("  QueueUrl: " + queueUrl);
        }
        System.out.println();

        // Send a message
        System.out.println("Sending a message to MyQueue.\n");
        sqs.sendMessage(new SendMessageRequest(myQueueUrl, "This is my message text."));

        // Receive messages
        System.out.println("Receiving messages from MyQueue.\n");
        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
        List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
        for (Message message : messages) {
            System.out.println("  Message");
            System.out.println("    MessageId:     " + message.getMessageId());
            System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
            System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
            System.out.println("    Body:          " + message.getBody());
            for (Entry<String, String> entry : message.getAttributes().entrySet()) {
                System.out.println("  Attribute");
                System.out.println("    Name:  " + entry.getKey());
                System.out.println("    Value: " + entry.getValue());
            }
        }
        System.out.println();

        // Delete a message
        System.out.println("Deleting a message.\n");
        String messageReceiptHandle = messages.get(0).getReceiptHandle();
        sqs.deleteMessage(new DeleteMessageRequest(myQueueUrl, messageReceiptHandle));

        /*            // Delete a queue
                    System.out.println("Deleting the test queue.\n");
                    sqs.deleteQueue(new DeleteQueueRequest(myQueueUrl));*/
    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SQS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with SQS, such as not "
                + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}

From source file:com.streamreduce.queue.CamelFacade.java

License:Apache License

private static SQSClientAndEndPointPair setupSqsEndpointAndClient(String queueName, String environment)
        throws UnsupportedEncodingException {
    Properties cloudProperties = PropertiesOverrideLoader.loadProperties("cloud.properties");
    String accessKeyId = cloudProperties.getProperty("nodeable.aws.accessKeyId");
    String secretKey = cloudProperties.getProperty("nodeable.aws.secretKey");
    long messageRetentionPeriod = TimeUnit.DAYS.toSeconds(14);
    String actualQueueName = SqsQueueNameFormatter.formatSqsQueueName(queueName, environment);

    AWSCredentials awsCredentials = new BasicAWSCredentials(accessKeyId, secretKey);
    AmazonSQSClient sqsClient = new AmazonSQSClient(awsCredentials);
    String endpoint = String.format(
            "aws-sqs://" + actualQueueName + "?amazonSQSClient=#amazonSQSClient&" + "messageRetentionPeriod=%d",
            messageRetentionPeriod);//from  w ww . java  2  s.  c  o m
    return new SQSClientAndEndPointPair(sqsClient, endpoint);
}

From source file:com.threewks.thundr.deferred.provider.SqsQueueProvider.java

License:Apache License

public SqsQueueProvider(AWSCredentials credentials, Region region, String deferredSqsQueueName) {
    AmazonSQSClient client = new AmazonSQSClient(credentials);
    client.setRegion(region);//from   w ww.java2s. c  o  m
    init(client, deferredSqsQueueName);
}

From source file:com.trsvax.tapestry.aws.core.services.AWSCoreModule.java

License:Apache License

public static void bind(ServiceBinder binder) {
    //binder.bind(AWSMailTransport.class,AWSMailTransportImpl.class);

    binder.bind(AmazonS3.class, new ServiceBuilder<AmazonS3>() {
        public AmazonS3 buildService(ServiceResources serviceResources) {
            return new AmazonS3Client(serviceResources.getService(AWSCredentials.class));
        }//from  ww w  . j a  v  a  2  s.com
    });
    binder.bind(AmazonDynamoDB.class, new ServiceBuilder<AmazonDynamoDB>() {
        public AmazonDynamoDB buildService(ServiceResources serviceResources) {
            return new AmazonDynamoDBClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonEC2.class, new ServiceBuilder<AmazonEC2>() {
        public AmazonEC2 buildService(ServiceResources serviceResources) {
            return new AmazonEC2Client(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonSimpleDB.class, new ServiceBuilder<AmazonSimpleDB>() {
        public AmazonSimpleDB buildService(ServiceResources serviceResources) {
            return new AmazonSimpleDBClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonSQS.class, new ServiceBuilder<AmazonSQS>() {
        public AmazonSQS buildService(ServiceResources serviceResources) {
            return new AmazonSQSClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonSNS.class, new ServiceBuilder<AmazonSNS>() {
        public AmazonSNS buildService(ServiceResources serviceResources) {
            return new AmazonSNSClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonRDS.class, new ServiceBuilder<AmazonRDS>() {
        public AmazonRDS buildService(ServiceResources serviceResources) {
            return new AmazonRDSClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonElasticMapReduce.class, new ServiceBuilder<AmazonElasticMapReduce>() {
        public AmazonElasticMapReduce buildService(ServiceResources serviceResources) {
            return new AmazonElasticMapReduceClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonSimpleEmailService.class, new ServiceBuilder<AmazonSimpleEmailService>() {
        public AmazonSimpleEmailService buildService(ServiceResources serviceResources) {
            return new AmazonSimpleEmailServiceClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonElasticLoadBalancing.class, new ServiceBuilder<AmazonElasticLoadBalancing>() {
        public AmazonElasticLoadBalancing buildService(ServiceResources serviceResources) {
            return new AmazonElasticLoadBalancingClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonCloudWatch.class, new ServiceBuilder<AmazonCloudWatch>() {
        public AmazonCloudWatch buildService(ServiceResources serviceResources) {
            return new AmazonCloudWatchClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonAutoScaling.class, new ServiceBuilder<AmazonAutoScaling>() {
        public AmazonAutoScaling buildService(ServiceResources serviceResources) {
            return new AmazonAutoScalingClient(serviceResources.getService(AWSCredentials.class));
        }
    });
    binder.bind(AmazonIdentityManagement.class, new ServiceBuilder<AmazonIdentityManagement>() {
        public AmazonIdentityManagement buildService(ServiceResources serviceResources) {
            return new AmazonIdentityManagementClient(serviceResources.getService(AWSCredentials.class));
        }
    });
}

From source file:com.tuprofe.api.SQSConfig.java

@Bean
public AmazonSQS amazonSQSClient() {
    AmazonSQS amazonSQS = new AmazonSQSClient(basicAWSCredentials());
    amazonSQS.setRegion(Region.getRegion(Regions.US_WEST_2));
    return amazonSQS;
}