usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [21/33] git commit: abstract queue messages
Date Fri, 05 Sep 2014 21:11:24 GMT
abstract queue messages


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

Branch: refs/heads/two-dot-o
Commit: 06db9e798df420e05760d3e3c7083915b9377e04
Parents: ddc219c
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Thu Aug 21 12:46:50 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Thu Aug 21 12:46:50 2014 -0600

----------------------------------------------------------------------
 .../NotificationsQueueManager.java              |  6 +--
 .../services/notifications/QueueMessage.java    | 43 ++++++++++++++++++++
 2 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/06db9e79/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsQueueManager.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsQueueManager.java
index f36a3de..23e3e62 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsQueueManager.java
@@ -74,7 +74,6 @@ public class NotificationsQueueManager implements NotificationServiceProxy
{
     private final InflectionUtils utils;
     private AtomicLong consecutiveEmptyQueues = new AtomicLong();
     private Long pushAutoExpireAfter = null;
-    static final String MESSAGE_PROPERTY_DEVICE_UUID = "deviceUUID";
 
     public final Map<String, ProviderAdapter> providerAdapters =   new HashMap<String,
ProviderAdapter>(3);
     {
@@ -173,8 +172,7 @@ public class NotificationsQueueManager implements NotificationServiceProxy
{
                                         sketch.add(hash,1);
                                     }
                                     maySchedule |= deviceCount.incrementAndGet() % BATCH_SIZE
== 0;
-                                    Message message = new Message();
-                                    message.setProperty(MESSAGE_PROPERTY_DEVICE_UUID, deviceRef.getUuid());
+                                    QueueMessage message = new QueueMessage(deviceRef);
                                     qm.postToQueue(queueName, message);
                                     if(notification.getQueued() == null){
                                         // update queued time
@@ -329,7 +327,7 @@ public class NotificationsQueueManager implements NotificationServiceProxy
{
                             return messageObservable.map(new Func1<Message, Message>()
{
                                 @Override
                                 public Message call(Message message) {
-                                    UUID deviceUUID = (UUID) message.getObjectProperty(MESSAGE_PROPERTY_DEVICE_UUID);
+                                    UUID deviceUUID =QueueMessage.generate(message).getUuid();
                                     boolean foundNotifier = false;
                                     for (Map.Entry<String, Object> entry : payloads.entrySet())
{
                                         try {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/06db9e79/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueMessage.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueMessage.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueMessage.java
new file mode 100644
index 0000000..065d6a3
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueMessage.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.services.notifications;
+
+import org.apache.usergrid.mq.Message;
+import org.apache.usergrid.persistence.EntityRef;
+
+import java.util.UUID;
+
+public class QueueMessage extends Message {
+
+    static final String MESSAGE_PROPERTY_DEVICE_UUID = "deviceUUID";
+
+    public QueueMessage() {
+    }
+
+    public QueueMessage(UUID deviceId){
+        this.setProperty(MESSAGE_PROPERTY_DEVICE_UUID,deviceId);
+    }
+
+    public QueueMessage(EntityRef deviceRef){
+        this.setProperty(MESSAGE_PROPERTY_DEVICE_UUID,deviceRef.getUuid());
+    }
+
+    public static QueueMessage generate(Message message){
+        return new QueueMessage((UUID) message.getObjectProperty(MESSAGE_PROPERTY_DEVICE_UUID));
+    }
+
+}


Mime
View raw message