Comments (8)
I agree with you.
一、对与原来设计的请求格式
{application Name}/{Interface name}?version={version}&group={group}
我觉得可以把version和group放到request header里面去,这样就可以不干扰普通的get请求。
二、 对与原来设计的请求参数
{
"methodName" : "sayHello",
"paramTypes" : ["org.apache.dubbo.demo.model.User"],
"paramValues": [
{
"id": 23,
"username": "testUser"
}
]
}
- 把methodName也放到请求路径上去;
- 把paramTypes去掉,没有必要,json是松散的,解析后能对应上,就作为参数处理,对应不上,就为空;
在请求头 增加参数解析与接口实际参数的匹配方式,可以做成3种等级:严格(每一个参数的名称和类型都要对应上)、较松散(参数的名称可以不完全一致,但类型必须一致)、松散(参数的名称和类型都可以不一致,全部对应不上,就全是空) - 最后,就只剩下真正的参数了,完全符合网关的要求了。
为了实现上面说的效果,不使用类似于过滤器的东西,好像是没有办法实现的吧
from dubbo-proxy.
I agree with you.
一、对与原来设计的请求格式{application Name}/{Interface name}?version={version}&group={group}
我觉得可以把version和group放到request header里面去,这样就可以不干扰普通的get请求。
二、 对与原来设计的请求参数
{
"methodName" : "sayHello",
"paramTypes" : ["org.apache.dubbo.demo.model.User"],
"paramValues": [
{
"id": 23,
"username": "testUser"
}
]
}
- 把methodName也放到请求路径上去;
- 把paramTypes去掉,没有必要,json是松散的,解析后能对应上,就作为参数处理,对应不上,就为空;
在请求头 增加参数解析与接口实际参数的匹配方式,可以做成3种等级:严格(每一个参数的名称和类型都要对应上)、较松散(参数的名称可以不完全一致,但类型必须一致)、松散(参数的名称和类型都可以不一致,全部对应不上,就全是空)- 最后,就只剩下真正的参数了,完全符合网关的要求了。
为了实现上面说的效果,不使用类似于过滤器的东西,好像是没有办法实现的吧
From me , I just want make it compatible with the old format.
So I just add code like this
private Splitter queryStringSplitter = Splitter.on(",").trimResults().omitEmptyStrings();
if (params.containsKey("methodName")) {
methodName = params.get("methodName").get(0);
}
if (params.containsKey("paramTypes")) {
@SuppressWarnings("UnstableApiUsage") List<String> paramTypesList = queryStringSplitter.splitToList(params.get("paramTypes").get(0));
if (!paramTypesList.isEmpty()) {
paramTypes = paramTypesList.toArray(new String[]{});
}
}
if (methodName != null && serviceDefinition.getMethodName() == null) {
serviceDefinition.setMethodName(methodName);
}
if (paramTypes != null && serviceDefinition.getParamTypes() == null) {
serviceDefinition.setParamTypes(paramTypes);
}
from dubbo-proxy.
paramTypes also need just because dubbo 2.6.x can not know the type
from dubbo-proxy.
@hbwhypw 如果必须用dubbo本身提供的泛化处理,其实这个是没办法处理的,但是如果要传递 xxx.xxx.bean, 这样其实是不友好的,除非我们不使用她的dubbo泛化,直接跳过这部分,到目标机器上
举个例子
正常的dubbo处理.
user ---> nginx ---> toncat#controller ----> 调用dubbo ---> dubbo#service处理
调用dubbo
这一步是tcp的,如果可以转化成 http
的就可以达到你这个效果了,其实就是直接将dubbo请求转化成http请求了,只是不经过controller,直接让service对她进行处理,这个是可以做到的,这样一来,前端直接发送所需要的参数即可,其他的全都不需要了.
from dubbo-proxy.
@hbwhypw 如果必须用dubbo本身提供的泛化处理,其实这个是没办法处理的,但是如果要传递 xxx.xxx.bean, 这样其实是不友好的,除非我们不使用她的dubbo泛化,直接跳过这部分,到目标机器上
举个例子
正常的dubbo处理.user ---> nginx ---> toncat#controller ----> 调用dubbo ---> dubbo#service处理
调用dubbo
这一步是tcp的,如果可以转化成http
的就可以达到你这个效果了,其实就是直接将dubbo请求转化成http请求了,只是不经过controller,直接让service对她进行处理,这个是可以做到的,这样一来,前端直接发送所需要的参数即可,其他的全都不需要了.
可以做网关录入啊 不需要手动写这个controller
目前我们会就是把这个部分通过录入固定参数的方式实现了
from dubbo-proxy.
@qixiaobo 一般dubbo转http主要是网关用的,也不是录入固定参数吧,我的实现就是类似与 Zuul
, 提供一个Servlet来处理. 然后借助Spring,直接invoke service,不经过controller。 可以这么说,对于业务其实都是无感知的。
from dubbo-proxy.
录入固定参数的意思把service这些名称录入进去 可以屏蔽这些 只需要关注参数和返回值
from dubbo-proxy.
可以试试,grpc-dubbo-proxy 直接封装为grpc服务,调用路径可以做到
nginx-> grpc-dubbo-proxy-> dubbo。
from dubbo-proxy.
Related Issues (20)
- dubbo 有自带的cache版的ReferenceConfig不需要Map做缓存
- We need handle with some error scenes HOT 1
- Dubbo proxy sometimes cannot response directly
- dubbo GenericInvoke throws exception local class incompatible HOT 1
- Not support multi address to register HOT 2
- 如果方法有泛型参数的话,调用报错。是不是还不支持泛型参数啊?
- 在当前master(2.7.5-snapshot)分支中demo模块启动失败,请关注AbstractInterfaceConfig该类实现 HOT 1
- dubbo提供了rest功能,为什么不使用这个对外提供接口? HOT 1
- dubbo-proxy应当增加安全访问机制,避免内部服务全通 HOT 6
- 一个提问,我看源码中根据Parmatypes.length加上方法名去判断是哪个元数据,不会出现重载的方法调用不到的情况吗
- 不能指定tomcat的端口吗
- 文件接口如何处理?
- 多个注册中心怎么处理? HOT 1
- 能支持nacos吗 HOT 1
- dubbo注册之后,发现org.springframework.aop.SpringProxy被注册到里面了,有人知道怎么回事吗
- dubbo 2.6.3 is support ? HOT 1
- dubbo group not set for reference HOT 1
- update dubbo version HOT 1
- Not support dubbo attachments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dubbo-proxy.