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

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

相关推荐
Nice__J5 分钟前
ISO26262功能安全——SafeOS
java·linux·安全
夹芯饼干21 分钟前
虚拟机指令第六节
java·linux·服务器
A_aspectJ1 小时前
【Java基础开发】基于 Java Swing +MySQL + JDBC 版实现图书管理系统
java·开发语言·mysql
TE-茶叶蛋1 小时前
Spring最核心扩展点:BeanPostProcessor
java·后端·spring
Mr.45671 小时前
SpringBoot多模块依赖冲突排查与架构优化实战(避坑指南)
java·spring boot·架构
学术阿凡提1 小时前
Spring Boot 优雅实现异步调用:从入门到自定义线程池与异常处理
java·数据库·算法
我是无敌小恐龙1 小时前
Java SE 零基础入门Day06 方法重载+Debug调试+String字符串全套API详解(超全干货)
java·开发语言·人工智能·python·transformer·无人机·量子计算
xiaoye37081 小时前
java接口文档工具 swagger2和swagger3对比
java·服务器·前端
三维频道1 小时前
工业级三维扫描实测:汽车灯具复杂结构件的全尺寸 3D 测量方案分析
java·人工智能·python·数码相机·3d·汽车·汽车轻量化制造
tongyiixiaohuang1 小时前
基于轻易云的数据集成,实现企业系统间灵活对接
java·前端·数据库