alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.91k stars 8.33k forks source link

How route the request to the right address? #696

Open fuyongde opened 5 years ago

fuyongde commented 5 years ago

I wrote a demo like spring-cloud-dubbo-provider-web-sample,but when I use the gateway to access dubbo service with dubbo protocol,it does not support route the right address that the same url with different params. You can access the demo. Start the product-serviceorder-service and gateway2,then access http://localhost:8083/dsc/order-service/orders/1?op=revoke,it will route this request to http://localhost:8083/dsc/order-service/orders/1?op=update. If your IDEA support .http file, just use /gateway-demo/request.http file. Hope to hear from you soon, sincerely.

fangjian0423 commented 5 years ago

hi, sorry for the late reply.

It seems this is a bug, define another method with different params can solve it.

@mercyblitz , these two methods could not match right in DubboServiceMetadataRepository:

@PutMapping(value = "/orders/{id}", params = "op=update")
@Override
public String update(@PathVariable Integer id, @RequestBody OrderUpdateRequest request) {
    productRpc.update(id, new ProductUpdateRequest(id, "product name", 10000L, 20));
    log.info("PUT product 4 update : id : {}, request {}", id, request);
    return "UPDATE SUCCESS";
}

@PutMapping(value = "/orders/{id}", params = "op=revoke")
@Override
public String revoke(@PathVariable Integer id, @RequestBody OrderRevokeRequest request) {
    productRpc.revoke(id, new ProductRevokeRequest(id, 1));
    log.info("PUT product 4 revoke, id : {}, request : {}", id, request);
    return "REVOKE SUCCESS";
}