Author: rajdavies
Date: Mon Feb 18 23:21:50 2008
New Revision: 629007

URL: http://svn.apache.org/viewvc?rev=629007&view=rev
Log:
doDispatch():
only apply message to least loaded if target subscription not 
already found

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=629007&r1=629006&r2=629007&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
 Mon Feb 18 23:21:50 2008
@@ -978,9 +978,8 @@
     }
     
     private void doDispatch(List<MessageReference> list) throws Exception {
-        
         if (list != null) {
-            synchronized (consumers) {      
+            synchronized (consumers) {
                 for (MessageReference node : list) {
                     Subscription target = null;
                     List<Subscription> targets = null;
@@ -998,9 +997,9 @@
                             }
                         }
                     }
-                    if (targets != null) {
-                        // pick the least loaded to add the messag too
-    
+                    if (target == null && targets != null) {
+                        // pick the least loaded to add the message too
+
                         for (Subscription s : targets) {
                             if (target == null
                                     || target.getInFlightUsage() > s
@@ -1012,11 +1011,12 @@
                             target.add(node);
                         }
                     }
-                    if (target != null && 
!dispatchSelector.isExclusiveConsumer(target)) {
+                    if (target != null
+                            && !dispatchSelector.isExclusiveConsumer(target)) {
                         consumers.remove(target);
                         consumers.add(target);
                     }
-    
+
                 }
             }
         }


Reply via email to