- make the group sequences 0 based to match producer message sequences which are also 0 based

- fixed bucket hashing method to handle cases where the group id hashes to a negative number.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@367676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-01-10 16:33:13 +00:00
parent 6397d0560b
commit a7785c6a54
2 changed files with 7 additions and 3 deletions

View File

@ -81,7 +81,7 @@ public class QueueSubscription extends PrefetchSubscription {
MessageGroupMap messageGroupOwners = ((Queue)node.getRegionDestination()).getMessageGroupOwners();
// If we can own the first, then no-one else should own the rest.
if( sequence==1 ) {
if( sequence==0 ) {
if( node.lock(this) ) {
messageGroupOwners.put(groupId, info.getConsumerId());
return true;
@ -107,7 +107,7 @@ public class QueueSubscription extends PrefetchSubscription {
if( groupOwner.equals(info.getConsumerId()) ) {
// A group sequence < 1 is an end of group signal.
if ( sequence < 1 ) {
if ( sequence < 0 ) {
messageGroupOwners.removeGroup(groupId);
}
return true;

View File

@ -102,6 +102,10 @@ public class MessageGroupHashBucket implements MessageGroupMap {
}
protected int getBucketNumber(String groupId) {
return groupId.hashCode() % bucketCount;
int bucket = groupId.hashCode() % bucketCount;
// bucket could be negative
if( bucket < 0 )
bucket *= -1;
return bucket;
}
}