VictoryAnn commented on issue #8904:
URL: https://github.com/apache/rocketmq/issues/8904#issuecomment-2553210157

   ### 先说结论:local mode 当前节点的proxy只能发送到本地的broker中,cluster 
mode则proxy可以进行全局topic的路由。
   (小声蛐蛐:local proxy的proxy概念有点误导常规对proxy的理解)
   
   先用客户端尝试一下 指定proxy地址,选择当前分片上不存在的topic,看是否会转发到另外一个分片。
   
![image](https://github.com/user-attachments/assets/f8fe5e38-e87c-4ff4-b38d-3bd009dc7b50)
   
![image](https://github.com/user-attachments/assets/28baf92f-cbb1-4074-ad46-9f2fbadeafed)
   
   
   这里可以看到客户端发送消息失败。
   
![image](https://github.com/user-attachments/assets/02272891-6a4f-40d4-b9af-1a696f96b989)
   
   跟踪客户端代码继续看,发现客户端报错是从proxy获取topicRoute报错,还没有走到sendMessage那一步,跟踪proxy代码,发现如下:
   LOCAL 模式下 获取topicRoute只从本地获取,所以客户端获取不到topic路由,然后终止发送消息。
   
![image](https://github.com/user-attachments/assets/3734e836-6c66-4cd7-87d1-a50f7e04acf9)
   
   CLUSTER模式下 是从topicCache中获取路由信息,topicCache是从nameserver获取的路由信息。
   
![image](https://github.com/user-attachments/assets/f3ddafe1-4d02-479c-b252-36b9c0a4332d)
   
![image](https://github.com/user-attachments/assets/d66d1db9-10da-4366-aa6f-2e981589c9e3)
   
   
   这个时候怀疑是不是proxy本身可以转发,但是由于客户端的缺陷或者是proxy提供route的api的问题导致无法发送成功。
   接下来,试一下直接调用grpc的sendmessage接口
   
![image](https://github.com/user-attachments/assets/6c0e34e6-8bf3-4f0a-975d-653837aa4aa5)
   
![image](https://github.com/user-attachments/assets/6d425a80-c996-4160-9f76-aef100c5c684)
   
   
   ```
   # grpc 调用接口 6666端口对应的broker-a 可以正常发送消息到broker-a的topic
   grpcurl -H 'client-id: astest' -plaintext -d 
'{"messages":[{"topic":{"name":"astest-1a"},"system_properties":{"tag":"messageTagA","keys":"messageKeyA","message_id":"0102427869DB29BF80074C8F3D00000001","body_encoding":"IDENTITY","message_type":"NORMAL","born_host":"BIH-L-56328ZZZ","queue_id":1},"body":"VGhpcyBpcyBhIG5vcm1hbCBtZXNzYWdlIGZvciBBcGFjaGUgUm9ja2V0TVEK"}]}'
 10.242.108.86:6666 apache.rocketmq.v2.MessagingService.SendMessage
   
   # grpc 调用接口 5555端口对应的broker-b 发送消息到broker-a的topic报错
   grpcurl -H 'client-id: astest' -plaintext -d 
'{"messages":[{"topic":{"name":"astest-1a"},"system_properties":{"tag":"messageTagA","keys":"messageKeyA","message_id":"0102427869DB29BF80074C8F3D00000001","body_encoding":"IDENTITY","message_type":"NORMAL","born_host":"BIH-L-56328ZZZ","queue_id":1},"body":"VGhpcyBpcyBhIG5vcm1hbCBtZXNzYWdlIGZvciBBcGFjaGUgUm9ja2V0TVEK"}]}'
 10.242.108.86:5555 apache.rocketmq.v2.MessagingService.SendMessage
   ```
   
![image](https://github.com/user-attachments/assets/6e0fcac6-a2e4-4fd9-8648-11e216ab75fb)
   
   看下源码的逻辑
   
![image](https://github.com/user-attachments/assets/78e642a6-9ffe-4dfb-80d3-3141b7fcf1b6)
   
   local mode 获取topic route是从broker controller中获取的,所以获取不到,但是cluster mode 
是从topicCache(从nameserver获取的)获取,这也证明了 local mode 只能发送到本地的队列,不能转发到其他proxy local 
的队列。(包括获取topic 之后,获取topic的message queue也一样,proxy local都是从本地获取)
   
![image](https://github.com/user-attachments/assets/87ce006a-38ef-4881-b6a4-47f7996e4b75)
   
![image](https://github.com/user-attachments/assets/f78b4802-7f50-4a8f-8b2a-66af725f4dcd)
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to