Do better handling of the reference counting during dispatch.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@359548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2005-12-28 15:34:06 +00:00
parent e58897bd69
commit a59fee46d5
1 changed files with 6 additions and 0 deletions

View File

@ -256,6 +256,8 @@ abstract public class PrefetchSubscription extends AbstractSubscription {
if( info.isDispatchAsync() ) { if( info.isDispatchAsync() ) {
md.setConsumer(new Runnable(){ md.setConsumer(new Runnable(){
public void run() { 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); onDispatch(node, message);
} }
}); });
@ -264,6 +266,10 @@ abstract public class PrefetchSubscription extends AbstractSubscription {
context.getConnection().dispatchSync(md); context.getConnection().dispatchSync(md);
onDispatch(node, message); 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();
} }
} }