apache / rocketmq-client-go

Apache RocketMQ go client

Home Page:https://rocketmq.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should unlock queue sending unlock(42) request to brokers where orderly consumer shutdown

qshuai opened this issue · comments

commented
commented

所以,go客户端需要在consumer关闭的时候主动向broker发起unlock请求,是这样的吗?

所以,go客户端需要在consumer关闭的时候主动向broker发起unlock请求,是这样的吗?

是的

如果是正常退出可以考虑加上unlock;
比如

trylock()
defer unlock()
xxxx

但是如果是异常或者程序interrupt,broker会在到期后强制转移使用权;

if (lockEntry.isExpired()) {
                            lockEntry.setClientId(clientId);
                            lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
                            log.warn(
                                "tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}",
                                group,
                                oldClientId,
                                clientId,
                                mq);
                            lockedMqs.add(mq);
                            continue;
 }

isExpired后,会强制将锁给到此时的请求者,完成所有权转换。

@qshuai @SchopenhauerZhang Hi, I have fixed it, please help me to review.