activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1075846 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Date Tue, 01 Mar 2011 15:26:01 GMT
Author: gtully
Date: Tue Mar  1 15:26:00 2011
New Revision: 1075846

URL: http://svn.apache.org/viewvc?rev=1075846&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3193 - rework of fix to always populate pagedInPending

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=1075846&r1=1075845&r2=1075846&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Tue Mar  1 15:26:00 2011
@@ -1437,23 +1437,6 @@ public class Queue extends BaseDestinati
                 } catch (Throwable e) {
                     LOG.error("Failed to page in more queue messages ", e);
                 }
-            } else {
-                // if there are already paged messages
-                // dispatch them
-                if (pagedInMessages.size() != 0) {
-                    pagedInMessagesLock.writeLock().lock();
-                    ArrayList paged = new ArrayList();
-                    try {
-                       paged.addAll(pagedInMessages.values());
-                    } finally {
-                       pagedInMessagesLock.writeLock().unlock();
-                    }
-                    try {
-                        doDispatch(paged);
-                    } catch (Exception e) {
-                       LOG.error("Failed to dispatch already paged messages ", e);
-                    }
-                }
             }
 
             if (pendingBrowserDispatch != null) {
@@ -1671,7 +1654,25 @@ public class Queue extends BaseDestinati
         return broker.getBrokerService().isSlave();
     }
 
-    private List<QueueMessageReference> doPageIn(boolean force) throws Exception {
+    private void doPageIn(boolean force) throws Exception {
+        List<QueueMessageReference> newlyPaged = doPageInForDispatch(force);
+        pagedInPendingDispatchLock.writeLock().lock();
+        try {
+            if (pagedInPendingDispatch.isEmpty()) {
+                pagedInPendingDispatch.addAll(newlyPaged);
+            } else {
+                for (QueueMessageReference qmr : newlyPaged) {
+                    if (!pagedInPendingDispatch.contains(qmr)) {
+                        pagedInPendingDispatch.add(qmr);
+                    }
+                }
+            }
+        } finally {
+            pagedInPendingDispatchLock.writeLock().unlock();
+        }
+    }
+
+    private List<QueueMessageReference> doPageInForDispatch(boolean force) throws Exception
{
         List<QueueMessageReference> result = null;
         List<QueueMessageReference> resultList = null;
 
@@ -1922,7 +1923,7 @@ public class Queue extends BaseDestinati
     }
 
     protected void pageInMessages(boolean force) throws Exception {
-        doDispatch(doPageIn(force));
+        doDispatch(doPageInForDispatch(force));
     }
 
     private void addToConsumerList(Subscription sub) {



Mime
View raw message