xunmengh opened a new issue #2685:
URL: https://github.com/apache/rocketmq/issues/2685


   rocketmq version 4.6.1
   producer use  broker public ip address.  Form some resaon ,  consumer need 
use broker another private ip addess.
   
   so I build two group namesrv ,one for producer ,other for comsumer,
   
   i modified  DefaultRequestProcessor  getRouteInfoByTopic method
   after
      ‘TopicRouteData topicRouteData = 
this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());’
   i add repalce brokerAddress method
   
   //TODO ADD replace brokerAddress adress
   
replaceBrokerAddress(topicRouteData,this.namesrvController.getKvConfigManager().getKVMapByNamespace(BROKER_IP_REPLACE_CONFIG));
   
   
    private static void replaceBrokerAddress( TopicRouteData topicRouteData, 
Map<String/* source*/, String /* target */ > map ) {
           log.info("repalce map:{}" ,map);
           List<BrokerData> brokerDataList =  topicRouteData.getBrokerDatas();
           if (brokerDataList !=null && map != null) {
               for(BrokerData brokerData : brokerDataList) {
                   HashMap<Long, String> addrsMap = brokerData.getBrokerAddrs();
                   if( addrsMap !=null) {
                       for(Map.Entry<Long, String> entry : addrsMap.entrySet()) 
{
                           String value = entry.getValue();
                           int index = value.lastIndexOf(":");
                           if(index != -1) {
                               String sourceIp = value.substring(0,index);
                               String targetIp = map.get(sourceIp);
                               if(targetIp != null) {
                                   
entry.setValue(value.replaceFirst(sourceIp,targetIp));
                               }
                           }
                       }
                   }
   
               }
           }
           log.info("repalce topicRouteData:{}" ,topicRouteData);
       }
   
   the consumer can get the  replaced address . 
   
   i'm not sure ,anthor place i need to modify , or have some better method .
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to