List of usage examples for com.amazonaws.services.sqs AmazonSQSClient AmazonSQSClient
AmazonSQSClient(AwsSyncClientParams clientParams)
From source file:com.jktsoftware.amazondownloader.queuemanager.DownloaderQueueManager.java
License:Open Source License
public void CreateQueues() { AWSCredentials awscredentials = new BasicAWSCredentials(this._credentials.getAccessKey(), this._credentials.getSecretAccessKey()); _sqs = new AmazonSQSClient(awscredentials); Region euWest1 = Region.getRegion(Regions.EU_WEST_1); _sqs.setRegion(euWest1);// ww w . j a va 2 s . c om System.out.println("Creating amazon download queues.\n"); CreateQueueRequest createReceivedQueueRequest = new CreateQueueRequest(_receivedqueuename); this._receivedqueueurl = _sqs.createQueue(createReceivedQueueRequest).getQueueUrl(); CreateQueueRequest createFailedQueueRequest = new CreateQueueRequest(_failedqueuename); this._failedqueueurl = _sqs.createQueue(createFailedQueueRequest).getQueueUrl(); }
From source file:com.leverno.ysbos.archive.example.AmazonGlacierDownloadInventoryWithSQSPolling.java
License:Open Source License
public static void main(String[] args) throws IOException { AWSCredentials credentials = AwsUtil.getCredentials(); client = new AmazonGlacierClient(credentials); client.setEndpoint("https://glacier." + region + ".amazonaws.com"); sqsClient = new AmazonSQSClient(credentials); sqsClient.setEndpoint("https://sqs." + region + ".amazonaws.com"); snsClient = new AmazonSNSClient(credentials); snsClient.setEndpoint("https://sns." + region + ".amazonaws.com"); try {/*from w w w. ja v a2 s . co m*/ setupSQS(); setupSNS(); String jobId = initiateJobRequest(); System.out.println("Jobid = " + jobId); Boolean success = waitForJobToComplete(jobId, sqsQueueURL); if (!success) { throw new Exception("Job did not complete successfully."); } downloadJobOutput(jobId); cleanUp(); } catch (Exception e) { System.err.println("Inventory retrieval failed."); System.err.println(e); } }
From source file:com.leverno.ysbos.archive.example.ArchiveDownloadHighLevel.java
License:Open Source License
public static void main(String[] args) throws IOException { AWSCredentials credentials = getCredentials(); AmazonSQSClient sqs = new AmazonSQSClient(credentials); AmazonSNSClient sns = new AmazonSNSClient(credentials); glacier = new AmazonGlacierClient(credentials); glacier.setEndpoint(Constants.endpoint); sqs.setEndpoint(Constants.endpoint); sns.setEndpoint(Constants.endpoint); try {/* w w w .j av a2s . co m*/ ArchiveTransferManager atm = new ArchiveTransferManager(glacier, sqs, sns); atm.download(vaultName, archiveId, new File(downloadFilePath)); } catch (Exception e) { System.err.println(e); } }
From source file:com.mateusz.mateuszsqs.SQSprocessor.java
public static void main(String[] args) throws AmazonClientException { System.out.println("Start process SQS"); try {/*from ww w.j av a2 s.c om*/ credentials = new ProfileCredentialsProvider().getCredentials(); } catch (Exception e) { System.out.println("Error"); 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); } final Thread mainThread = new Thread(() -> { while (!Thread.currentThread().isInterrupted()) { AmazonSQS sqs = new AmazonSQSClient(credentials); Region usWest2 = Region.getRegion(Regions.US_WEST_2); sqs.setRegion(usWest2); AmazonS3 s3 = new AmazonS3Client(credentials); s3.setRegion(usWest2); List<String> filesList = SQSConfig.getMessages(sqs, sqsURL); for (String file : filesList) { String[] files = file.split(","); if (!file.equals("missing parameter: fileNames")) for (int i = 0; i < files.length; i++) { try { SQSConfig.processFile(files[i], s3, bucketName); } catch (IOException e) { System.out.println("Error"); e.printStackTrace(); } } } System.out.println("\nWaiting for messages.........\n"); } }); mainThread.start(); }
From source file:com.mycompany.rproject.runnableClass.java
public static void use() throws IOException { AWSCredentials awsCreds = new PropertiesCredentials( new File("/Users/paulamontojo/Desktop/AwsCredentials.properties")); AmazonSQS sqs = new AmazonSQSClient(awsCreds); Region usWest2 = Region.getRegion(Regions.US_WEST_2); sqs.setRegion(usWest2);/* w ww . j a v a2 s.co m*/ String myQueueUrl = "https://sqs.us-west-2.amazonaws.com/711690152696/MyQueue"; System.out.println("Receiving messages from MyQueue.\n"); ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl); List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); while (messages.isEmpty()) { messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); } String messageRecieptHandle = messages.get(0).getReceiptHandle(); String a = messages.get(0).getBody(); sqs.deleteMessage(new DeleteMessageRequest(myQueueUrl, messageRecieptHandle)); //aqui opero y cuando acabe llamo para operar el siguiente. String n = ""; String dbName = "mydb"; String userName = "pmontojo"; String password = "pmontojo"; String hostname = "mydb.cued7orr1q2t.us-west-2.rds.amazonaws.com"; String port = "3306"; String jdbcUrl = "jdbc:mysql://" + hostname + ":" + port + "/" + dbName + "?user=" + userName + "&password=" + password; Connection conn = null; Statement setupStatement = null; Statement readStatement = null; ResultSet resultSet = null; String results = ""; int numresults = 0; String statement = null; try { conn = DriverManager.getConnection(jdbcUrl); setupStatement = conn.createStatement(); String insertUrl = "select video_name from metadata where id = " + a + ";"; String checkUrl = "select url from metadata where id = " + a + ";"; ResultSet rs = setupStatement.executeQuery(insertUrl); rs.next(); System.out.println("este es el resultdo " + rs.getString(1)); String names = rs.getString(1); ResultSet ch = setupStatement.executeQuery(checkUrl); ch.next(); System.out.println("este es la url" + ch.getString(1)); String urli = ch.getString(1); while (urli == null) { ResultSet sh = setupStatement.executeQuery(checkUrl); sh.next(); System.out.println("este es la url" + sh.getString(1)); urli = sh.getString(1); } setupStatement.close(); AmazonS3 s3Client = new AmazonS3Client(awsCreds); S3Object object = s3Client.getObject(new GetObjectRequest(bucketName, names)); IOUtils.copy(object.getObjectContent(), new FileOutputStream(new File("/Users/paulamontojo/Desktop/download.avi"))); putOutput(); write(); putInDb(sbu.toString(), a); } catch (SQLException ex) { // handle any errors System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } finally { System.out.println("Closing the connection."); if (conn != null) try { conn.close(); } catch (SQLException ignore) { } } use(); }
From source file:com.netflix.bdp.s3mper.alert.impl.AlertJanitor.java
License:Apache License
public void initalize(URI uri, Configuration conf) { this.conf = conf; String keyId = conf.get("fs." + uri.getScheme() + ".awsAccessKeyId"); String keySecret = conf.get("fs." + uri.getScheme() + ".awsSecretAccessKey"); //An override option for accessing across accounts keyId = conf.get("fs." + uri.getScheme() + ".override.awsAccessKeyId", keyId); keySecret = conf.get("fs." + uri.getScheme() + ".override.awsSecretAccessKey", keySecret); sqs = new AmazonSQSClient(new BasicAWSCredentials(keyId, keySecret)); //SQS Consistency Queue consistencyQueue = conf.get("fs" + uri.getScheme() + ".alert.sqs.queue", consistencyQueue); consistencyQueue = sqs.getQueueUrl(new GetQueueUrlRequest(consistencyQueue)).getQueueUrl(); //SQS Timeout Queue timeoutQueue = conf.get("fs" + uri.getScheme() + ".timeout.sqs.queue", timeoutQueue); timeoutQueue = sqs.getQueueUrl(new GetQueueUrlRequest(timeoutQueue)).getQueueUrl(); }
From source file:com.netflix.bdp.s3mper.alert.impl.CloudWatchAlertDispatcher.java
License:Apache License
private void initSqs(String keyId, String keySecret) { log.debug("Initializing SQS Client"); sqs = new AmazonSQSClient(new BasicAWSCredentials(keyId, keySecret)); //SQS Consistency Queue consistencyQueue = conf.get("s3mper.alert.sqs.queue", consistencyQueue); consistencyQueueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(consistencyQueue)).getQueueUrl(); //SQS Timeout Queue timeoutQueue = conf.get("s3mper.timeout.sqs.queue", timeoutQueue); timeoutQueueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(timeoutQueue)).getQueueUrl(); //SQS Notification Queue notificationQueue = conf.get("s3mper.notification.sqs.queue", notificationQueue); notificationQueueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(notificationQueue)).getQueueUrl(); //Disable reporting (Testing purposes mostly) reportingDisabled = conf.getBoolean("s3mper.reporting.disabled", reportingDisabled); }
From source file:com.netflix.conductor.contribs.ContribsModule.java
License:Apache License
@Provides public Map<Status, ObservableQueue> getQueues(Configuration config, AWSCredentialsProvider acp) { String stack = ""; if (config.getStack() != null && config.getStack().length() > 0) { stack = config.getStack() + "_"; }/*from w w w .j a v a 2s . c o m*/ Status[] statuses = new Status[] { Status.COMPLETED, Status.FAILED }; Map<Status, ObservableQueue> queues = new HashMap<>(); for (Status status : statuses) { String queueName = config.getProperty("workflow.listener.queue.prefix", config.getAppId() + "_sqs_notify_" + stack + status.name()); AmazonSQSClient client = new AmazonSQSClient(acp); Builder builder = new SQSObservableQueue.Builder().withClient(client).withQueueName(queueName); String auth = config.getProperty("workflow.listener.queue.authorizedAccounts", ""); String[] accounts = auth.split(","); for (String accountToAuthorize : accounts) { accountToAuthorize = accountToAuthorize.trim(); if (accountToAuthorize.length() > 0) { builder.addAccountToAuthorize(accountToAuthorize.trim()); } } ObservableQueue queue = builder.build(); queues.put(status, queue); } return queues; }
From source file:com.ninetoseven.inmuebles.AmazonClientManager.java
License:Open Source License
private void initClients() { AWSCredentials credentials = AmazonSharedPreferencesWrapper .getCredentialsFromSharedPreferences(this.sharedPreferences); Region region = Region.getRegion(Regions.US_EAST_1); s3Client = new AmazonS3Client(credentials); s3Client.setRegion(region);/*from w w w . j a v a 2 s .c o m*/ sqsClient = new AmazonSQSClient(credentials); sqsClient.setRegion(region); sdbClient = new AmazonSimpleDBClient(credentials); sdbClient.setRegion(region); snsClient = new AmazonSNSClient(credentials); snsClient.setRegion(region); }
From source file:com.pinterest.teletraan.worker.LaunchEventCollector.java
License:Apache License
public LaunchEventCollector(TeletraanServiceContext context) { agentDAO = context.getAgentDAO();/*from w ww .j a v a2 s .c o m*/ asgLifecycleEventDAO = context.getAsgLifecycleEventDAO(); groupDAO = context.getGroupDAO(); groupInfoDAO = context.getGroupInfoDAO(); hostDAO = context.getHostDAO(); newInstanceReportDAO = context.getNewInstanceReportDAO(); utilDAO = context.getUtilDAO(); eventMessageParser = new EventMessageParser(); autoScaleGroupManager = context.getAutoScaleGroupManager(); sqsClient = new AmazonSQSClient(context.getAwsCredentials()); sqsClient.setEndpoint(context.getAwsConfigManager().getSqsArn()); }