RpcServiceContext上下文

消费者: web

提供者: buss-service

同一服务器: 192.168.100.228

java 复制代码
RpcServiceContext serviceContext = RpcContext.getServiceContext();
//web->buss-service

LOGGER.warn("getRequest->{}", JsonUtil.toJson(serviceContext.getRequest()));
//getRequest->null
LOGGER.warn("getResponse->{}", JsonUtil.toJson(serviceContext.getResponse()));
//getResponse->null
LOGGER.warn("get->{}", JsonUtil.toJson(serviceContext.get()));
//get->{}
LOGGER.warn("getAttachments->{}", JsonUtil.toJson(serviceContext.getAttachments()));
//getAttachments->{"traceId":"aaef470a3a164379b4f12517f743f5d6","input":"392","remote.application":"web"}
LOGGER.warn("getInterfaceName->{}", JsonUtil.toJson(serviceContext.getInterfaceName()));
//getInterfaceName->null
LOGGER.warn("getLocalAddressString->{}", JsonUtil.toJson(serviceContext.getLocalAddressString()));
//getLocalAddressString->192.168.100.228:21000
LOGGER.warn("getLocalHost->{}", JsonUtil.toJson(serviceContext.getLocalHost()));
//getLocalHost->192.168.100.228
LOGGER.warn("getLocalHostName->{}", JsonUtil.toJson(serviceContext.getLocalHostName()));
//getLocalHostName->192.168.100.228
LOGGER.warn("getLocalPort->{}", JsonUtil.toJson(serviceContext.getLocalPort()));
//getLocalPort->21000
LOGGER.warn("getMethodName->{}", JsonUtil.toJson(serviceContext.getMethodName()));
//getMethodName->test
LOGGER.warn("getObjectAttachments->{}", JsonUtil.toJson(serviceContext.getObjectAttachments()));
//getObjectAttachments->{"traceId":"aaef470a3a164379b4f12517f743f5d6","input":"392","remote.application":"web"}
LOGGER.warn("getRemoteAddressString->{}", JsonUtil.toJson(serviceContext.getRemoteAddressString()));
//getRemoteAddressString->192.168.100.228:36992
LOGGER.warn("getRemoteApplicationName->{}", JsonUtil.toJson(serviceContext.getRemoteApplicationName()));
//getRemoteApplicationName->web
LOGGER.warn("getRemoteHost->{}", JsonUtil.toJson(serviceContext.getRemoteHost()));
//getRemoteHost->192.168.100.228
LOGGER.warn("getRemoteHostName->{}", JsonUtil.toJson(serviceContext.getRemoteHostName()));
//getRemoteHostName->saas-network-01
LOGGER.warn("getRemotePort->{}", JsonUtil.toJson(serviceContext.getRemotePort()));
//getRemotePort->36992
URL url = serviceContext.getUrl();
if(url != null) {
	LOGGER.warn("getAbsolutePath->{}", JsonUtil.toJson(url.getAbsolutePath()));
    //getAbsolutePath->/com.myb.wh.buss.service.base.FileService
	LOGGER.warn("getAddress->{}", JsonUtil.toJson(url.getAddress()));
    //getAddress->192.168.100.228:21000
	LOGGER.warn("getAllParameters->{}", JsonUtil.toJson(url.getAllParameters()));
    //getAllParameters->{"release":"3.1.0","dubbo":"2.0.2","interface":"com.myb.wh.buss.service.base.FileService","application":"buss-service","anyhost":"true","pid":"3178994","side":"provider","metadata-type":"remote","methods":"copyFile,deleteFile,getUploadParam,deleteFolder,test,upload,html2Jpg,getFilesByDirectory,ofd2Pdf,jpg2Pdf,batchDeleteFile,html2Pdf,watermarkDIY","logger":"slf4j","deprecated":"false","service-name-mapping":"true","qos.enable":"false","timeout":"10000","bind.port":"21000","register-mode":"instance","generic":"false","bind.ip":"192.168.100.228","payload":"8388608","background":"false","dynamic":"true","service.filter":"dubboExceptionFilter,-exception","dispatcher":"message","qos.accept.foreign.ip":"false","timestamp":"1700834530470"}
	LOGGER.warn("getParameters->{}", JsonUtil.toJson(url.getParameters()));
    //getParameters->{"release":"3.1.0","dubbo":"2.0.2","interface":"com.myb.wh.buss.service.base.FileService","application":"buss-service","anyhost":"true","pid":"3178994","side":"provider","metadata-type":"remote","methods":"copyFile,deleteFile,getUploadParam,deleteFolder,test,upload,html2Jpg,getFilesByDirectory,ofd2Pdf,jpg2Pdf,batchDeleteFile,html2Pdf,watermarkDIY","logger":"slf4j","deprecated":"false","service-name-mapping":"true","qos.enable":"false","timeout":"10000","bind.port":"21000","register-mode":"instance","generic":"false","bind.ip":"192.168.100.228","payload":"8388608","background":"false","dynamic":"true","service.filter":"dubboExceptionFilter,-exception","dispatcher":"message","qos.accept.foreign.ip":"false","timestamp":"1700834530470"}
	LOGGER.warn("getPath->{}", JsonUtil.toJson(url.getPath()));
    //getPath->com.myb.wh.buss.service.base.FileService
	LOGGER.warn("getServiceInterface->{}", JsonUtil.toJson(url.getServiceInterface()));
    //getServiceInterface->com.myb.wh.buss.service.base.FileService
	LOGGER.warn("getServiceKey->{}", JsonUtil.toJson(url.getServiceKey()));
    //getServiceKey->com.myb.wh.buss.service.base.FileService
	LOGGER.warn("getSide->{}", JsonUtil.toJson(url.getSide()));
    //getSide->provider
	LOGGER.warn("getIp->{}", JsonUtil.toJson(url.getIp()));
    //getIp->192.168.100.228
	LOGGER.warn("getApplication->{}", JsonUtil.toJson(url.getApplication()));
    //getApplication->buss-service
	LOGGER.warn("getBackupAddress->{}", JsonUtil.toJson(url.getBackupAddress()));
    //getBackupAddress->192.168.100.228:21000
	LOGGER.warn("getHost->{}", JsonUtil.toJson(url.getHost()));
    //getHost->192.168.100.228
	LOGGER.warn("getPort->{}", JsonUtil.toJson(url.getPort()));
    //getPort->21000
	LOGGER.warn("getRemoteApplication->{}", JsonUtil.toJson(url.getRemoteApplication()));
    //getRemoteApplication->null
	LOGGER.warn("getServiceName->{}", JsonUtil.toJson(url.getServiceName()));
    //getServiceName->com.myb.wh.buss.service.base.FileService
	LOGGER.warn("getSide->{}", JsonUtil.toJson(url.getSide()));
    //getSide->provider
	ServiceModel serviceModel = url.getServiceModel();
	if(serviceModel != null) {
		LOGGER.warn("getServiceKey->{}", JsonUtil.toJson(serviceModel.getServiceKey()));
		//getServiceKey->com.myb.wh.buss.service.base.FileService
        LOGGER.warn("getServiceName->{}", JsonUtil.toJson(serviceModel.getServiceName()));
        //getServiceName->com.myb.wh.buss.service.base.FileService
	}
}
			
URL consumerUrl = serviceContext.getConsumerUrl();
if(consumerUrl != null) { //为null
	LOGGER.warn("getAbsolutePath->{}", JsonUtil.toJson(consumerUrl.getAbsolutePath()));
	LOGGER.warn("getAddress->{}", JsonUtil.toJson(consumerUrl.getAddress()));
	LOGGER.warn("getAllParameters->{}", JsonUtil.toJson(consumerUrl.getAllParameters()));
	LOGGER.warn("getApplication->{}", JsonUtil.toJson(consumerUrl.getApplication()));
	LOGGER.warn("getAttributes->{}", JsonUtil.toJson(consumerUrl.getAttributes()));
	LOGGER.warn("getBackupAddress->{}", JsonUtil.toJson(consumerUrl.getBackupAddress()));
	LOGGER.warn("getAuthority->{}", JsonUtil.toJson(consumerUrl.getAuthority()));
	LOGGER.warn("getCategory->{}", JsonUtil.toJson(consumerUrl.getCategory()));
	LOGGER.warn("getIp->{}", JsonUtil.toJson(consumerUrl.getIp()));
	LOGGER.warn("getPath->{}", JsonUtil.toJson(consumerUrl.getPath()));
	LOGGER.warn("getParametersv", JsonUtil.toJson(consumerUrl.getParameters()));
	LOGGER.warn("getPort->{}", JsonUtil.toJson(consumerUrl.getPort()));
	LOGGER.warn("getHost->{}", JsonUtil.toJson(consumerUrl.getHost()));
	LOGGER.warn("getRemoteApplication->{}", JsonUtil.toJson(consumerUrl.getRemoteApplication()));
	LOGGER.warn("getServiceInterface->{}", JsonUtil.toJson(consumerUrl.getServiceInterface()));
	LOGGER.warn("getServiceName->{}", JsonUtil.toJson(consumerUrl.getServiceName()));
	LOGGER.warn("getSide->{}", JsonUtil.toJson(consumerUrl.getSide()));
	LOGGER.warn("getServiceKey->{}", JsonUtil.toJson(consumerUrl.getServiceKey()));
	ServiceModel serviceModel = consumerUrl.getServiceModel();
	if(serviceModel != null) {
		LOGGER.warn("getServiceKey->{}", JsonUtil.toJson(serviceModel.getServiceKey()));
		LOGGER.warn("getServiceName->{}", JsonUtil.toJson(serviceModel.getServiceName()));
		}
	}
}

上述为执行内容, 后面在碰到其它场景, 再补充吧, 一般够用了

相关推荐
掐指一算乀缺钱14 分钟前
SpringBoot 数据库表结构文档生成
java·数据库·spring boot·后端·spring
晚睡早起₍˄·͈༝·͈˄*₎◞ ̑̑19 分钟前
苍穹外卖学习笔记(七)
java·windows·笔记·学习·mybatis
就这个java爽!25 分钟前
JAVA网络编程【基于TCP和UDP协议】超详细!!!
java·开发语言·网络·tcp/ip·udp·eclipse·idea
一叶飘零_sweeeet29 分钟前
为什么 Feign 要用 HTTP 而不是 RPC?
java·网络协议·http·spring cloud·rpc·feign
懒洋洋大魔王1 小时前
7.Java高级编程 多线程
java·开发语言·jvm
茶馆大橘1 小时前
【黑马点评】已解决java.lang.NullPointerException异常
java·开发语言
星辰@Sea1 小时前
服务注册中心对比及使用场景分析
java·云原生
马剑威(威哥爱编程)1 小时前
除了递归算法,要如何优化实现文件搜索功能
java·开发语言·算法·递归算法·威哥爱编程·memoization
bug菌¹1 小时前
滚雪球学SpringCloud[4.1讲]: Spring Cloud Gateway详解
java·spring cloud·微服务
MuseLss1 小时前
HashMap高频面试知识点
java·开发语言·哈希算法