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()));
		}
	}
}

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

相关推荐
Bs_MoneyMagnet14 分钟前
基于springboot+vue的爱心众筹系统的设计与实现 源码+文档
java·vue.js·spring boot·后端·spring·管理系统
名字还没想好☜28 分钟前
Java Collectors.groupingBy 进阶:多级分组、下游收集器与统计聚合一次搞定
java·windows·后端·python·spring
Wang's Blog32 分钟前
Java框架快速入门: Spring Security+OAuth2之前端按钮级安全与路由守卫
java·安全·spring
ocean21031 小时前
2025-2026年Java语言及生态面试高频知识点洞察
java·开发语言·面试
2302_1111 小时前
java时间类型
java·开发语言
用户8181870627461 小时前
第25章 Redis集群脑裂实录:一次真实故障复盘
java·后端
运行时异常1 小时前
【WMS 仓储系统集成 AI Agent 实战】第 6 讲:RAG 知识库——“输出简单流程“为什么检索不到任何东西
java
小七在进步1 小时前
类和对象(三)
java·开发语言
夜不会漫长1 小时前
C++:类和对象(1)
java·开发语言·c++
czt_java1 小时前
Java文件IO核心知识点总结
java·开发语言