usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [72/82] [abbrv] git commit: change method to get queue url
Date Wed, 22 Oct 2014 21:12:14 GMT
change method to get queue url


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

Branch: refs/heads/two-dot-o-events
Commit: 170699b4b07d4276d3a8016b35de0b37b313d333
Parents: 19556e2
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Oct 22 09:09:52 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Oct 22 09:09:52 2014 -0600

----------------------------------------------------------------------
 .../persistence/queue/impl/SQSQueueManagerImpl.java  | 15 ++++++++-------
 .../services/notifications/QueueListener.java        | 10 +++++-----
 2 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/170699b4/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
index caf5691..72276bc 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
@@ -87,13 +87,14 @@ public class SQSQueueManagerImpl implements QueueManager {
     }
     public Queue getQueue(){
         if(queue == null) {
-            ListQueuesResult result =  sqs.listQueues();
-            for (String queueUrl : result.getQueueUrls()) {
-                boolean found = queueUrl.contains(getName());
-                if (found) {
-                    queue = new Queue(queueUrl);
-                    break;
-                }
+            try {
+                GetQueueUrlResult result = sqs.getQueueUrl(getName());
+                queue = new Queue(result.getQueueUrl());
+            }catch (QueueDoesNotExistException queueDoesNotExistException){
+                queue=null;
+            }catch (Exception e){
+                LOG.error("failed to get queue from service",e);
+                throw e;
             }
         }
         if(queue == null) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/170699b4/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index ca6a71c..3ef9198 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -135,14 +135,14 @@ public class QueueListener  {
         LOG.info("QueueListener: Starting execute process.");
         Meter meter = metricsService.getMeter(QueueListener.class, "queue");
         com.codahale.metrics.Timer timer = metricsService.getTimer(QueueListener.class, "dequeue");
-
+        svcMgr = smf.getServiceManager(smf.getManagementAppId());
+        LOG.info("getting from queue {} ", queueName);
+        QueueScope queueScope = new QueueScopeImpl(new SimpleId(smf.getManagementAppId(),ApplicationQueueManager.QUEUE_PREFIX),queueName);
+        QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
         // run until there are no more active jobs
         while ( true ) {
             try {
-                svcMgr = smf.getServiceManager(smf.getManagementAppId());
-                LOG.info("getting from queue {} ", queueName);
-                QueueScope queueScope = new QueueScopeImpl(new SimpleId(smf.getManagementAppId(),ApplicationQueueManager.QUEUE_PREFIX),queueName);
-                QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER
: queueManagerFactory.getQueueManager(queueScope);
+
                 Timer.Context timerContext = timer.time();
                 List<QueueMessage> messages = queueManager.getMessages(getBatchSize(),
MESSAGE_TRANSACTION_TIMEOUT, 5000, ApplicationQueueMessage.class);
                 LOG.info("retrieved batch of {} messages from queue {} ", messages.size(),queueName);


Mime
View raw message