LevonHe opened a new issue, #1345: URL: https://github.com/apache/rocketmq-clients/issues/1345
### Before Creating the Bug Report - [x] I found a bug, not just asking a question, which should be created in [GitHub Discussions](https://github.com/apache/rocketmq-clients/discussions). - [x] I have searched the [GitHub Issues](https://github.com/apache/rocketmq-clients/issues) and [GitHub Discussions](https://github.com/apache/rocketmq-clients/discussions) of this repository and believe that this is not a duplicate. - [x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ. ### Programming Language of the Client Go ### Runtime Platform Environment Linux ### RocketMQ Version of the Client/Server Client: golang/v5.1.2, v5.1.3, v5.1.4 and current master Server: RocketMQ 5.x compatible server ### Run or Compiler Version Go 1.24+ ### Describe the Bug The Go Producer does not filter message queues by broker role and write permission in `NewPublishingLoadBalancer` or `CopyAndUpdate`. When the route contains slave queues, the Producer may select a slave and attempt to send messages to it. The Java SDK already filters publishing queues using: ```Java mq.getPermission().isWritable() && Utilities.MASTER_BROKER_ID == mq.getBroker().getId() ``` ### Steps to Reproduce Create a route containing a writable master queue and a slave queue, then call: ```Go loadBalancer, _ := NewPublishingLoadBalancer(queues) candidates, _ := loadBalancer.TakeMessageQueues(&sync.Map{}, len(queues)) ``` The returned candidates may contain the slave queue. The same issue occurs after `CopyAndUpdate`. ### What Did You Expect to See? The Producer should only select queues that satisfy: ```Go mq.GetBroker().GetId() == 0 && (mq.GetPermission() == v2.Permission_WRITE || mq.GetPermission() == v2.Permission_READ_WRITE) ``` If no writable master exists, queue selection should fail. ### What Did You See Instead? The Producer may select a slave queue. The server then rejects the request with an error similar to: ```text service not available now ... messages are put to the slave ``` ### Additional Context This issue was reproduced in a RocketMQ 5.x-compatible environment. Filtering slave and non-writable queues resolved the send failure. The fix should cover both initial route creation and route refresh. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
