Skip to content

RocketMQ 5.x,当使用Proxy时消费者无法从slave节点拉取消息 #9261

Answered by francisoliverlee
lemoay asked this question in Q&A
Discussion options

You must be logged in to vote

使用remoting客户端是的。方法是: findBrokerAddressInSubscribe(), AI解释如下:
流程说明:

  1. 首先检查brokerName是否为空,如果为空则直接返回null
  2. 检查brokerAddrTable中是否存在该brokerName,如果不存在或为空则返回null
  3. 根据传入的brokerId查找对应的broker地址
  4. 如果未找到且是slave,则尝试查找brokerId+1的地址
  5. 如果仍未找到且不要求只查找该broker,则取第一个broker地址
  6. 根据找到的broker地址判断是master还是slave
  7. 返回FindBrokerResult对象,包含broker地址、是否slave和broker版本信息

这个方法主要用于在订阅场景下查找指定broker的地址,支持查找master和slave,并且可以根据brokerId精确查找或随机查找。

实现代码

public FindBrokerResult findBrokerAddressInSubscribe(
final String brokerName,
final long brokerId,
final boolean onlyThisBroker
) {
if (b…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lemoay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants