Don't init queue in constructor

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

Branch: refs/heads/usergrid-1318-queue
Commit: 832b505c75724ed61a2d5869727208cbabf5ce13
Parents: 6f983a4
Author: Dave Johnson <snoopd...@apache.org>
Authored: Fri Sep 16 14:54:35 2016 -0400
Committer: Dave Johnson <snoopd...@apache.org>
Committed: Fri Sep 16 14:54:35 2016 -0400

----------------------------------------------------------------------
 .../persistence/queue/impl/QakkaQueueManager.java         | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/832b505c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java
 
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java
index c407a78..832cecd 100644
--- 
a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java
+++ 
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java
@@ -65,6 +65,10 @@ public class QakkaQueueManager implements LegacyQueueManager 
{
         this.qakkaFig = qakkaFig;
         this.queueMessageManager = queueMessageManager;
         this.regions = regions;
+    }
+
+
+    private synchronized void createQueueIfNecessary() {
 
         if ( queueManager.getQueueConfig(scope.getName()) == null ) {
 
@@ -80,6 +84,8 @@ public class QakkaQueueManager implements LegacyQueueManager {
     @Override
     public <T extends Serializable> void sendMessage(T body) throws 
IOException {
 
+        createQueueIfNecessary();
+
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(bos);
         oos.writeObject(body);
@@ -106,6 +112,8 @@ public class QakkaQueueManager implements 
LegacyQueueManager {
     @Override
     public List<LegacyQueueMessage> getMessages(int limit, Class klass) {
 
+        createQueueIfNecessary();
+
         List<LegacyQueueMessage> messages = new ArrayList<>();
         List<QueueMessage> qakkaMessages = 
queueMessageManager.getNextMessages( scope.getName(), limit );
 
@@ -147,6 +155,8 @@ public class QakkaQueueManager implements 
LegacyQueueManager {
     @Override
     public void commitMessage(LegacyQueueMessage queueMessage) {
 
+        createQueueIfNecessary();
+
         UUID queueMessageId  = UUID.fromString( queueMessage.getMessageId() );
         queueMessageManager.ackMessage( scope.getName(), queueMessageId );
     }

Reply via email to