Author: chirino
Date: Wed Dec 28 07:34:06 2005
New Revision: 359548

URL: http://svn.apache.org/viewcvs?rev=359548&view=rev
Log:
Do better handling of the reference counting during dispatch.

Modified:
    
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/region/PrefetchSubscription.java

Modified: 
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/region/PrefetchSubscription.java
URL: 
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/region/PrefetchSubscription.java?rev=359548&r1=359547&r2=359548&view=diff
==============================================================================
--- 
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/region/PrefetchSubscription.java
 (original)
+++ 
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/region/PrefetchSubscription.java
 Wed Dec 28 07:34:06 2005
@@ -256,6 +256,8 @@
             if( info.isDispatchAsync() ) {
                 md.setConsumer(new Runnable(){
                     public void run() {
+                        // Since the message gets queued up in async dispatch, 
we don't want to 
+                        // decrease the reference count until it gets put on 
the wire.
                         onDispatch(node, message);
                     }
                 });
@@ -264,6 +266,10 @@
                 context.getConnection().dispatchSync(md);
                 onDispatch(node, message);
             }
+            // The onDispatch() does the node.decrementReferenceCount();
+        } else {
+            // We were not allowed to dispatch that message (an other consumer 
grabbed it before we did)
+            node.decrementReferenceCount();
         }
         
     }


Reply via email to