mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-19 02:23:24 +08:00
[ISSUE #8804] clean offset when remove group offset
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.apache.rocketmq.broker.offset;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -110,4 +111,25 @@ public class LmqConsumerOffsetManager extends ConsumerOffsetManager {
|
||||
public void setLmqOffsetTable(ConcurrentHashMap<String, Long> lmqOffsetTable) {
|
||||
this.lmqOffsetTable = lmqOffsetTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOffset(String group) {
|
||||
if (!MixAll.isLmq(group)) {
|
||||
super.removeOffset(group);
|
||||
return;
|
||||
}
|
||||
Iterator<Map.Entry<String, Long>> it = this.lmqOffsetTable.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, Long> next = it.next();
|
||||
String topicAtGroup = next.getKey();
|
||||
if (topicAtGroup.contains(group)) {
|
||||
String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
|
||||
if (arrays.length == 2 && group.equals(arrays[1])) {
|
||||
it.remove();
|
||||
removeConsumerOffset(topicAtGroup);
|
||||
LOG.warn("clean lmq group offset {}", topicAtGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user