Telnet 命令扩展

扩展说明

所有服务器均支持 telnet 访问,用于人工干预。

扩展接口

com.alibaba.dubbo.remoting.telnet.TelnetHandler

扩展配置

  1. <dubbo:protocol telnet="xxx,yyy" />
  2. <!-- 缺省值设置,当<dubbo:protocol>没有配置telnet属性时,使用此配置 -->
  3. <dubbo:provider telnet="xxx,yyy" />

已知扩展

  • com.alibaba.dubbo.remoting.telnet.support.ClearTelnetHandler
  • com.alibaba.dubbo.remoting.telnet.support.ExitTelnetHandler
  • com.alibaba.dubbo.remoting.telnet.support.HelpTelnetHandler
  • com.alibaba.dubbo.remoting.telnet.support.StatusTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.ListTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.ChangeTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.CurrentTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.InvokeTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.TraceTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.CountTelnetHandler
  • com.alibaba.dubbo.rpc.dubbo.telnet.PortTelnetHandler

    扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxTelnetHandler.java (实现TelnetHandler接口)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-com.alibaba.dubbo.remoting.telnet.TelnetHandler (纯文本文件,内容为:xxx=com.xxx.XxxTelnetHandler)

XxxTelnetHandler.java:

  1. package com.xxx;
  2. import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
  3. @Help(parameter="...", summary="...", detail="...")
  4. public class XxxTelnetHandler implements TelnetHandler {
  5. public String telnet(Channel channel, String message) throws RemotingException {
  6. // ...
  7. }
  8. }

META-INF/dubbo/com.alibaba.dubbo.remoting.telnet.TelnetHandler:

  1. xxx=com.xxx.XxxTelnetHandler

用法

  1. telnet 127.0.0.1 20880
  2. dubbo> xxx args

原文: http://dubbo.apache.org/#!/docs/dev/impls/telnet-handler.md?lang=zh-cn