diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java index 81e6d8468ebf1d303330cd4ff21b91f79be58b8a..976dcba17de6bde92e827ae19be61c1e7f78d637 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java @@ -863,7 +863,7 @@ public class MQClientInstance { } } - public boolean registerConsumer(final String group, final MQConsumerInner consumer) { + public synchronized boolean registerConsumer(final String group, final MQConsumerInner consumer) { if (null == group || null == consumer) { return false; } @@ -877,9 +877,9 @@ public class MQClientInstance { return true; } - public void unregisterConsumer(final String group) { + public synchronized void unregisterConsumer(final String group) { this.consumerTable.remove(group); - this.unregisterClientWithLock(null, group); + this.unregisterClient(null, group); } private void unregisterClientWithLock(final String producerGroup, final String consumerGroup) {