Telnet 命令扩展

Telnet 命令扩展

扩展说明

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

扩展接口

org.apache.dubbo.remoting.telnet.TelnetHandler

扩展配置

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

已知扩展

  • org.apache.dubbo.remoting.telnet.support.ClearTelnetHandler
  • org.apache.dubbo.remoting.telnet.support.ExitTelnetHandler
  • org.apache.dubbo.remoting.telnet.support.HelpTelnetHandler
  • org.apache.dubbo.remoting.telnet.support.StatusTelnetHandler
  • org.apache.dubbo.rpc.dubbo.telnet.ListTelnetHandler
  • org.apache.dubbo.rpc.dubbo.telnet.ChangeTelnetHandler
  • org.apache.dubbo.rpc.dubbo.telnet.CurrentTelnetHandler
  • org.apache.dubbo.rpc.dubbo.telnet.InvokeTelnetHandler
  • org.apache.dubbo.rpc.dubbo.telnet.TraceTelnetHandler
  • org.apache.dubbo.rpc.dubbo.telnet.CountTelnetHandler
  • org.apache.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. |-org.apache.dubbo.remoting.telnet.TelnetHandler (纯文本文件,内容为:xxx=com.xxx.XxxTelnetHandler)

XxxTelnetHandler.java:

  1. package com.xxx;
  2. import org.apache.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/org.apache.dubbo.remoting.telnet.TelnetHandler:

  1. xxx=com.xxx.XxxTelnetHandler

命令用法

  1. telnet 127.0.0.1 20880
  2. dubbo> xxx args

最后修改 June 28, 2023: Update telnet-handler.md (#2705) (4c153fde698)