提交 800421ee 编写于 作者: S sunhangda

registerProducer & unregisterProducer add synchronization too, how about

add for producer
上级 8eb275f5
......@@ -882,24 +882,6 @@ public class MQClientInstance {
this.unregisterClient(null, group);
}
private void unregisterClientWithLock(final String producerGroup, final String consumerGroup) {
try {
if (this.lockHeartbeat.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
this.unregisterClient(producerGroup, consumerGroup);
} catch (Exception e) {
log.error("unregisterClient exception", e);
} finally {
this.lockHeartbeat.unlock();
}
} else {
log.warn("lock heartBeat, but failed. [{}]", this.clientId);
}
} catch (InterruptedException e) {
log.warn("unregisterClientWithLock exception", e);
}
}
private void unregisterClient(final String producerGroup, final String consumerGroup) {
Iterator<Entry<String, HashMap<Long, String>>> it = this.brokerAddrTable.entrySet().iterator();
while (it.hasNext()) {
......@@ -927,7 +909,7 @@ public class MQClientInstance {
}
}
public boolean registerProducer(final String group, final DefaultMQProducerImpl producer) {
public synchronized boolean registerProducer(final String group, final DefaultMQProducerImpl producer) {
if (null == group || null == producer) {
return false;
}
......@@ -941,9 +923,9 @@ public class MQClientInstance {
return true;
}
public void unregisterProducer(final String group) {
public synchronized void unregisterProducer(final String group) {
this.producerTable.remove(group);
this.unregisterClientWithLock(group, null);
this.unregisterClient(group, null);
}
public boolean registerAdminExt(final String group, final MQAdminExtInner admin) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册