usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [2/6] incubator-usergrid git commit: Convert Amazon SNS client to the async SNS client.
Date Thu, 02 Jul 2015 19:28:57 GMT
Convert Amazon SNS client to the async SNS client.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ddeb700b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ddeb700b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ddeb700b

Branch: refs/heads/two-dot-o-dev
Commit: ddeb700be52e06cf5a8eb722c6238f943317f3a3
Parents: 446a8e8
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Wed Jul 1 17:23:59 2015 -0700
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Wed Jul 1 17:23:59 2015 -0700

----------------------------------------------------------------------
 .../queue/impl/SNSQueueManagerImpl.java         | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ddeb700b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
index 4812e55..12e04ce 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
@@ -21,7 +21,7 @@ package org.apache.usergrid.persistence.queue.impl;
 import com.amazonaws.AmazonServiceException;
 import com.amazonaws.regions.Region;
 import com.amazonaws.regions.Regions;
-import com.amazonaws.services.sns.AmazonSNSClient;
+import com.amazonaws.services.sns.AmazonSNSAsyncClient;
 import com.amazonaws.services.sns.model.*;
 import com.amazonaws.services.sns.util.Topics;
 import com.amazonaws.services.sqs.AmazonSQSClient;
@@ -54,7 +54,7 @@ public class SNSQueueManagerImpl implements QueueManager {
     private final QueueFig fig;
     private final ClusterFig clusterFig;
     private final AmazonSQSClient sqs;
-    private final AmazonSNSClient sns;
+    private final AmazonSNSAsyncClient sns;
 
 
     private final JsonFactory JSON_FACTORY = new JsonFactory();
@@ -171,7 +171,7 @@ public class SNSQueueManagerImpl implements QueueManager {
                 Region region = Region.getRegion(regions);
 
                 final AmazonSQSClient sqsClient = createSQSClient(region);
-                final AmazonSNSClient snsClient = createSNSClient(region);
+                final AmazonSNSAsyncClient snsClient = createSNSClient(region);
 
                 String topicArn = AmazonNotificationUtils.getTopicArn(snsClient, queueName,
true);
 
@@ -210,7 +210,7 @@ public class SNSQueueManagerImpl implements QueueManager {
                     Regions snsRegions = Regions.fromName(strSnsRegion);
                     Region snsRegion = Region.getRegion(snsRegions);
 
-                    final AmazonSNSClient snsClient = createSNSClient(snsRegion);
+                    final AmazonSNSAsyncClient snsClient = createSNSClient(snsRegion);
 
                     try {
 
@@ -244,9 +244,9 @@ public class SNSQueueManagerImpl implements QueueManager {
     }
 
 
-    private AmazonSNSClient createSNSClient(final Region region) {
+    private AmazonSNSAsyncClient createSNSClient(final Region region) {
         final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
-        final AmazonSNSClient sns = new AmazonSNSClient(ugProvider.getCredentials());
+        final AmazonSNSAsyncClient sns = new AmazonSNSAsyncClient(ugProvider.getCredentials());
 
         sns.setRegion(region);
 
@@ -363,10 +363,12 @@ public class SNSQueueManagerImpl implements QueueManager {
 
         if (logger.isDebugEnabled()) logger.debug("Publishing Message...{} to arn: {}", stringBody,
topicArn);
 
-        PublishResult publishResult = sns.publish(topicArn, toString(body));
+        PublishRequest publishRequest = new PublishRequest(topicArn, toString(body));
+
+        sns.publishAsync(publishRequest);
+
+        // see about implementing asyncHandler for publishAsync in future
 
-        if (logger.isDebugEnabled())
-            logger.debug("Published Message ID: {} to arn: {}", publishResult.getMessageId(),
topicArn);
     }
 
 


Mime
View raw message