Cczzzz opened a new pull request #1801: add client custom nameserver 
TopAddressing
URL: https://github.com/apache/rocketmq/pull/1801
 
 
   I change TopAddressing to interface.
   ```
   public interface TopAddressing {
   
       String fetchNSAddr();
   
       void registerChangeCallBack(Consumer<String> changeCallBack);
   }
   ```
   Uesr can ues ServiceLoader to loading  custom  TopAddressing implementation. 
When there is a custom implementation,Custom implementations are preferred.
   ```
      private TopAddressing findCustomTopAddressing() {
           ServiceLoader<TopAddressing> serviceLoader = 
ServiceLoader.load(TopAddressing.class);
           Iterator<TopAddressing> iterator = serviceLoader.iterator();
           if (iterator.hasNext()) {
               return iterator.next();
           }
           return null;
       }
   ```
   I also provide a way to call back.this is a methods in interface 
TopAddressing. MQClientAPIImpl will register  call back  function to perception 
changes 
   ```
     this.topAddressing.registerChangeCallBack(this::fetchNameServerAddr);
   ```

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


With regards,
Apache Git Services

Reply via email to