Telnet 调试Dubbo服务

Dubbo2.0.5以上版本服务提供端口支持telnet命令,我们可以通过telnet命令进行调试dubbo服务,官方参考

  1. 连接服务,首先安装telnet工具
    telnet 172.18.100.241 20888
  2. 常用命令
    status [-l] - Show status.
    pwd - Print working default service.
    trace [service] [method] [times] - Trace the service.
    exit - Exit the telnet.
    help [command] - Show help.
    invoke [service.]method(args) - Invoke the service method.
    count [service] [method] [times] - Count the service.
    clear [lines] - Clear screen.
    ls [-l] [service] - List services and methods.
    log level - Change log level or show log
    ps [-l] [port] - Print server ports and connections.
    cd [service] - Change default service.

  3. 查看提供服务的接口
    dubbo>ls
    cn.nhorizon.ads.monitor.hourservice.CmsMonitorHourService
    cn.nhorizon.ads.monitor.service.CmsAntiCheatService
    cn.nhorizon.ads.monitor.service.CmsMonitorService

  4. 接口名对外提供的方法
    dubbo>ls cn.nhorizon.ads.monitor.service.CmsMonitorService
    getAllPublisher
    getSlotByMediaId
    getAdSlotHourlyInfoByAid

  5. 调用服务进行测试 : invoke 接口名.方法名(参数) 进行调用
    dubbo>invoke cn.nhorizon.ads.monitor.service.CmsMonitorService.getAllPublisher({})
    [{“publisherId”:”fb3b6ef0f89741f68087ae249c6059d9”,”publisherName”:”测试”,”mediasVos”:null,”pid”:-1006346001}{“publisherId”:”f25797c113b04f4baede05549d0d7e63”,”publisherName”:”测到”,”mediasVos”:null,”pid”:2086367568}]
    elapsed: 10 ms.