blob: 87ce98821db9a97da6c3ffdd80392af561955046 [file] [log] [blame]
<!doctype html><html lang=en class=no-js><head><meta name=ROBOTS content="INDEX, FOLLOW"><link rel=canonical href=https://cn.dubbo.apache.org/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/><script>var _hmt=_hmt||[];(function(){var e,t=document.createElement("script");t.src="https://hm.baidu.com/hm.js?3b78f49ba47181e4d998a66b689446e9",e=document.getElementsByTagName("script")[0],e.parentNode.insertBefore(t,e)})()</script><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta http-equiv=Content-Security-Policy content="frame-src *"><meta name=generator content="Hugo 0.122.0"><link rel="shortcut icon" type=image/png href=/imgs/favicon.png><link rel=apple-touch-icon href=/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=manifest href=/manifest.webmanifest><title>How to proxy Dubbo service in Apache ShenYu Gateway | Apache Dubbo</title><meta property="og:title" content="How to proxy Dubbo service in Apache ShenYu Gateway">
<meta property="og:description" content="This article describes how to access the `Dubbo` service through the `Apache ShenYu` gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles."><meta property="og:type" content="article"><meta property="og:url" content="https://cn.dubbo.apache.org/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/"><meta property="article:section" content="blog"><meta property="article:published_time" content="2022-05-04T00:00:00+00:00"><meta property="article:modified_time" content="2023-02-23T11:00:42+08:00"><meta itemprop=name content="How to proxy Dubbo service in Apache ShenYu Gateway"><meta itemprop=description content="This article describes how to access the `Dubbo` service through the `Apache ShenYu` gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles."><meta itemprop=datePublished content="2022-05-04T00:00:00+00:00"><meta itemprop=dateModified content="2023-02-23T11:00:42+08:00"><meta itemprop=wordCount content="2792"><meta itemprop=keywords content><meta name=twitter:card content="summary"><meta name=twitter:title content="How to proxy Dubbo service in Apache ShenYu Gateway"><meta name=twitter:description content="This article describes how to access the `Dubbo` service through the `Apache ShenYu` gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles."><script async src="https://www.googletagmanager.com/gtag/js?id=G-NM6FFMT51J"></script><script>var doNotTrack=!1;if(!doNotTrack){window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag("js",new Date),gtag("config","G-NM6FFMT51J",{anonymize_ip:!1})}</script><link rel=preload href=/scss/main.min.f77e221bcdbe0cadb996060fe82063c747b60c229a1f8bbf0ee529adbadd84fa.css as=style><link href=/scss/main.min.f77e221bcdbe0cadb996060fe82063c747b60c229a1f8bbf0ee529adbadd84fa.css rel=stylesheet integrity><script src=/js/jquery-3.5.1.min.js integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin=anonymous></script><meta name=theme-color content="#326ce5"><link rel=stylesheet href=/css/feature-states.css><meta name=description content="This article describes how to access the `Dubbo` service through the `Apache ShenYu` gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles."><meta property="og:description" content="This article describes how to access the `Dubbo` service through the `Apache ShenYu` gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles."><meta name=twitter:description content="This article describes how to access the `Dubbo` service through the `Apache ShenYu` gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles."><meta property="og:url" content="https://cn.dubbo.apache.org/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/"><meta property="og:title" content="How to proxy Dubbo service in Apache ShenYu Gateway"><meta name=twitter:title content="How to proxy Dubbo service in Apache ShenYu Gateway"><meta name=twitter:image:alt content="Apache Dubbo"><meta property="og:image" content="/imgs/blog/shenyu-dubbo/ApacheShenYu-Dubbo-en.png"><meta property="og:type" content="article"><meta name=viewport content="width=device-width"><script async defer src=/js/github-buttons.js></script><link href=/css/community.css rel=stylesheet><link href=/css/contactus.css rel=stylesheet><link href=/css/language.css rel=stylesheet><script src=/js/script.js></script></head><body class="td-page td-documentation"><header><nav class="js-navbar-scroll navbar navbar-expand navbar-dark flex-column flex-md-row td-navbar" data-auto-burger=primary><a class=navbar-brand href=/en/><span class=navbar-logo></span><span class="text-uppercase font-weight-bold">Apache Dubbo</span></a><div class="td-navbar-nav-scroll ml-md-auto" id=main_navbar><ul class="navbar-nav mt-2 mt-lg-0"><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=/en/overview/><span>Overview</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=/en/docs3-v2/><span>SDK Manual</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class="nav-link active" href=/en/blog/><span class=active>Blog</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=/en/download/><span>Download</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=https://start.dubbo.apache.org/bootstrap.html target=_blank><span>Initializer</span><i class='fas fa-external-link-alt'></i></a></li><li class="nav-item dropdown d-lg-block"><a class="nav-link dropdown-toggle" href=# id=navbarDropdownMenuLink role=button data-toggle=dropdown aria-haspopup=true aria-expanded=false>English</a><div class="dropdown-menu dropdown-menu-right" aria-labelledby=navbarDropdownMenuLink><a class=dropdown-item href=/zh-cn/>δΈ­ζ–‡</a></div></li><li class="nav-item dropdown d-lg-block"><div class="nav-item d-none d-lg-block"></div></li></ul></div></nav><section class="header-hero text-white pb-0 light-text"></section></header><div class="container-fluid td-outer"><div class=td-main><div class="row flex-md-nowrap"><div class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none"><script>$(function(){$("#td-section-nav a").removeClass("active"),$("#td-section-nav #m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway").addClass("active"),$("#td-section-nav #m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway-li span").addClass("td-sidebar-nav-active-item"),$("#td-section-nav #m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway").parents("li").addClass("active-path"),$("#td-section-nav li.active-path").addClass("show"),$("#td-section-nav li.active-path").children("input").prop("checked",!0),$("#td-section-nav #m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway-li").siblings("li").addClass("show"),$("#td-section-nav #m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway-li").children("ul").children("li").addClass("show"),$("#td-sidebar-menu").toggleClass("d-none")})</script><div id=td-sidebar-menu class="td-sidebar__inner d-none"><div id=content-mobile><form class="td-sidebar__search d-flex align-items-center"><button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type=button data-toggle=collapse data-target=#td-section-nav aria-controls=td-docs-nav aria-expanded=false aria-label="Toggle section navigation"></button></form></div><div id=content-desktop></div><nav class="collapse td-sidebar-nav foldable-nav" id=td-section-nav><ul class="td-sidebar-nav__section pr-md-3 ul-0"><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-enblog-li><ul class=ul-1><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-enblognews-li><input type=checkbox id=m-enblognews-check>
<label for=m-enblognews-check><a href=/en/blog/news/ title="Articles About Apache Dubbo" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-enblognews><span>Articles</span></a></label><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20240131tracing-dubbo-with-opentelemetry-li><input type=checkbox id=m-enblog20240131tracing-dubbo-with-opentelemetry-check>
<label for=m-enblog20240131tracing-dubbo-with-opentelemetry-check><a href=/en/blog/2024/01/31/tracing-dubbo-with-opentelemetry/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20240131tracing-dubbo-with-opentelemetry><span>Tracing Dubbo With OpenTelemetry</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20231023introduction-to-apache-dubbo-plugin-for-intellij-idea-li><input type=checkbox id=m-enblog20231023introduction-to-apache-dubbo-plugin-for-intellij-idea-check>
<label for=m-enblog20231023introduction-to-apache-dubbo-plugin-for-intellij-idea-check><a href=/en/blog/2023/10/23/introduction-to-apache-dubbo-plugin-for-intellij-idea/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20231023introduction-to-apache-dubbo-plugin-for-intellij-idea><span>Introduction to Apache Dubbo plugin for IntelliJ IDEA</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20230415advanced-cloud-native-dubbo-32-officially-released-li><input type=checkbox id=m-enblog20230415advanced-cloud-native-dubbo-32-officially-released-check>
<label for=m-enblog20230415advanced-cloud-native-dubbo-32-officially-released-check><a href=/en/blog/2023/04/15/advanced-cloud-native-dubbo-3.2-officially-released/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20230415advanced-cloud-native-dubbo-32-officially-released><span>Advanced cloud native - Dubbo 3.2 officially released</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway-li><input type=checkbox id=m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway-check>
<label for=m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway-check><a href=/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20220504how-to-proxy-dubbo-service-in-apache-shenyu-gateway><span>How to proxy Dubbo service in Apache ShenYu Gateway</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20220118makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix-li><input type=checkbox id=m-enblog20220118makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix-check>
<label for=m-enblog20220118makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix-check><a href=/en/blog/2022/01/18/makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20220118makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix><span>Makes it More Convenient for You to Proxy Dubbo Services in Apache APISIX</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190826service-test-li><input type=checkbox id=m-enblog20190826service-test-check>
<label for=m-enblog20190826service-test-check><a href=/en/blog/2019/08/26/service-test/ title="Dubbo Admin service test" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190826service-test><span>Service test in dubbo admin</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190811tracing-dubbo-service-with-apache-skywalking-li><input type=checkbox id=m-enblog20190811tracing-dubbo-service-with-apache-skywalking-check>
<label for=m-enblog20190811tracing-dubbo-service-with-apache-skywalking-check><a href=/en/blog/2019/08/11/tracing-dubbo-service-with-apache-skywalking/ title="Tracing Dubbo service with Apache Skywalking" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190811tracing-dubbo-service-with-apache-skywalking><span>Use apache skywalking in dubbo</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190502dubbo-extensible-mechanism-source-code-analysis-part-2-li><input type=checkbox id=m-enblog20190502dubbo-extensible-mechanism-source-code-analysis-part-2-check>
<label for=m-enblog20190502dubbo-extensible-mechanism-source-code-analysis-part-2-check><a href=/en/blog/2019/05/02/dubbo-extensible-mechanism-source-code-analysis-part-2/ title="Dubbo extensible mechanism source code analysis - part 2" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190502dubbo-extensible-mechanism-source-code-analysis-part-2><span>Dubbo extensible mechanism - part 2</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190425dubbo-extensible-mechanism-source-code-analysis-part-1-li><input type=checkbox id=m-enblog20190425dubbo-extensible-mechanism-source-code-analysis-part-1-check>
<label for=m-enblog20190425dubbo-extensible-mechanism-source-code-analysis-part-1-check><a href=/en/blog/2019/04/25/dubbo-extensible-mechanism-source-code-analysis-part-1/ title="Dubbo extensible mechanism source code analysis - part 1" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190425dubbo-extensible-mechanism-source-code-analysis-part-1><span>Dubbo extensible mechanism - part 1</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190220implementation-background-and-practice-of-dubbo-client-asynchronous-interface-li><input type=checkbox id=m-enblog20190220implementation-background-and-practice-of-dubbo-client-asynchronous-interface-check>
<label for=m-enblog20190220implementation-background-and-practice-of-dubbo-client-asynchronous-interface-check><a href=/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-client-asynchronous-interface/ title="Implementation background and practice of Dubbo client asynchronous interface" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190220implementation-background-and-practice-of-dubbo-client-asynchronous-interface><span>Dubbo Async Client</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190220implementation-background-and-practice-of-dubbo-server-asynchronous-interface-li><input type=checkbox id=m-enblog20190220implementation-background-and-practice-of-dubbo-server-asynchronous-interface-check>
<label for=m-enblog20190220implementation-background-and-practice-of-dubbo-server-asynchronous-interface-check><a href=/en/blog/2019/02/20/implementation-background-and-practice-of-dubbo-server-asynchronous-interface/ title="Implementation background and practice of Dubbo server asynchronous interface" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190220implementation-background-and-practice-of-dubbo-server-asynchronous-interface><span>Dubbo Async Server</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20190117how-to-use-seata-to-ensure-consistency-between-dubbo-microservices-li><input type=checkbox id=m-enblog20190117how-to-use-seata-to-ensure-consistency-between-dubbo-microservices-check>
<label for=m-enblog20190117how-to-use-seata-to-ensure-consistency-between-dubbo-microservices-check><a href=/en/blog/2019/01/17/how-to-use-seata-to-ensure-consistency-between-dubbo-microservices/ title="How to use Seata to ensure consistency between Dubbo Microservices" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20190117how-to-use-seata-to-ensure-consistency-between-dubbo-microservices><span>Use Seata in Dubbo</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20181210the-fifth-dubbo-meetup-has-been-held-in-hangzhou-li><input type=checkbox id=m-enblog20181210the-fifth-dubbo-meetup-has-been-held-in-hangzhou-check>
<label for=m-enblog20181210the-fifth-dubbo-meetup-has-been-held-in-hangzhou-check><a href=/en/blog/2018/12/10/the-fifth-dubbo-meetup-has-been-held-in-hangzhou/ title="The fifth Dubbo meetup has been held in Hangzhou" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20181210the-fifth-dubbo-meetup-has-been-held-in-hangzhou><span>The fifth Dubbo meetup</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20181107dubbo-integrates-with-nacos-to-become-a-registry-li><input type=checkbox id=m-enblog20181107dubbo-integrates-with-nacos-to-become-a-registry-check>
<label for=m-enblog20181107dubbo-integrates-with-nacos-to-become-a-registry-check><a href=/en/blog/2018/11/07/dubbo-integrates-with-nacos-to-become-a-registry/ title="Dubbo Integrates with Nacos to Become a Registry" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20181107dubbo-integrates-with-nacos-to-become-a-registry><span>Use Dubbo with Nacos</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20181005introduction-to-the-dubbo-protocol-li><input type=checkbox id=m-enblog20181005introduction-to-the-dubbo-protocol-check>
<label for=m-enblog20181005introduction-to-the-dubbo-protocol-check><a href=/en/blog/2018/10/05/introduction-to-the-dubbo-protocol/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20181005introduction-to-the-dubbo-protocol><span>Introduction to the Dubbo protocol</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180930integrate-dubbo-with-kubernetes-li><input type=checkbox id=m-enblog20180930integrate-dubbo-with-kubernetes-check>
<label for=m-enblog20180930integrate-dubbo-with-kubernetes-check><a href=/en/blog/2018/09/30/integrate-dubbo-with-kubernetes/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180930integrate-dubbo-with-kubernetes><span>Integrate Dubbo with Kubernetes</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180902how-to-prepare-an-apache-release-li><input type=checkbox id=m-enblog20180902how-to-prepare-an-apache-release-check>
<label for=m-enblog20180902how-to-prepare-an-apache-release-check><a href=/en/blog/2018/09/02/how-to-prepare-an-apache-release/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180902how-to-prepare-an-apache-release><span>How to prepare an Apache Release</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180902how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo-li><input type=checkbox id=m-enblog20180902how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo-check>
<label for=m-enblog20180902how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo-check><a href=/en/blog/2018/09/02/how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo/ title="How to implement a fully asynchronous calls chain based on Dubbo" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180902how-to-implement-a-fully-asynchronous-calls-chain-based-on-dubbo><span>New Async Call</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180826the-fourth-dubbo-meetup-has-been-held-in-chengdu-li><input type=checkbox id=m-enblog20180826the-fourth-dubbo-meetup-has-been-held-in-chengdu-check>
<label for=m-enblog20180826the-fourth-dubbo-meetup-has-been-held-in-chengdu-check><a href=/en/blog/2018/08/26/the-fourth-dubbo-meetup-has-been-held-in-chengdu/ title="The fourth Dubbo meetup has been held in Chengdu" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180826the-fourth-dubbo-meetup-has-been-held-in-chengdu><span>The fourth Dubbo meetup</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814dubbo-basic-usage-dubbo-consumer-configuration-li><input type=checkbox id=m-enblog20180814dubbo-basic-usage-dubbo-consumer-configuration-check>
<label for=m-enblog20180814dubbo-basic-usage-dubbo-consumer-configuration-check><a href=/en/blog/2018/08/14/dubbo-basic-usage-dubbo-consumer-configuration/ title=" Dubbo Basic Usage - Dubbo Consumer Configuration" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814dubbo-basic-usage-dubbo-consumer-configuration><span>Dubbo Consumer Configuration</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814dubbo-several-ways-about-synchronousasynchronous-invoke-li><input type=checkbox id=m-enblog20180814dubbo-several-ways-about-synchronousasynchronous-invoke-check>
<label for=m-enblog20180814dubbo-several-ways-about-synchronousasynchronous-invoke-check><a href=/en/blog/2018/08/14/dubbo-several-ways-about-synchronous/asynchronous-invoke/ title="Dubbo: Several ways about synchronous/asynchronous invoke" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814dubbo-several-ways-about-synchronousasynchronous-invoke><span>Dubbo Invoke</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814dubbo-basic-usage--dubbo-provider-configuration-li><input type=checkbox id=m-enblog20180814dubbo-basic-usage--dubbo-provider-configuration-check>
<label for=m-enblog20180814dubbo-basic-usage--dubbo-provider-configuration-check><a href=/en/blog/2018/08/14/dubbo-basic-usage--dubbo-provider-configuration/ title="Dubbo Basic Usage -- Dubbo Provider Configuration" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814dubbo-basic-usage--dubbo-provider-configuration><span>Dubbo Provider Configuration</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814manipulating-services-dynamically-via-qos-li><input type=checkbox id=m-enblog20180814manipulating-services-dynamically-via-qos-check>
<label for=m-enblog20180814manipulating-services-dynamically-via-qos-check><a href=/en/blog/2018/08/14/manipulating-services-dynamically-via-qos/ title="Manipulating Services Dynamically via QoS" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814manipulating-services-dynamically-via-qos><span>Dubbo QoS Introduction</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814source-code-analysis-of-spring-boot-dubbo-app-start-and-stop-li><input type=checkbox id=m-enblog20180814source-code-analysis-of-spring-boot-dubbo-app-start-and-stop-check>
<label for=m-enblog20180814source-code-analysis-of-spring-boot-dubbo-app-start-and-stop-check><a href=/en/blog/2018/08/14/source-code-analysis-of-spring-boot-dubbo-app-start-and-stop/ title="Source code analysis of spring-boot+Dubbo App start and stop" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814source-code-analysis-of-spring-boot-dubbo-app-start-and-stop><span>Dubbo start/stop in spring boot</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814implementation-of-cross-language-calls-by-dubbo2js-li><input type=checkbox id=m-enblog20180814implementation-of-cross-language-calls-by-dubbo2js-check>
<label for=m-enblog20180814implementation-of-cross-language-calls-by-dubbo2js-check><a href=/en/blog/2018/08/14/implementation-of-cross-language-calls-by-dubbo2.js/ title="Implementation of cross-language calls by Dubbo2.js" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814implementation-of-cross-language-calls-by-dubbo2js><span>dubbo2.js introduction</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814generic-invoke-of-dubbo-li><input type=checkbox id=m-enblog20180814generic-invoke-of-dubbo-check>
<label for=m-enblog20180814generic-invoke-of-dubbo-check><a href=/en/blog/2018/08/14/generic-invoke-of-dubbo/ title="Generic invoke of Dubbo" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814generic-invoke-of-dubbo><span>Generic invoke</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180814native-image-using-graalvm-li><input type=checkbox id=m-enblog20180814native-image-using-graalvm-check>
<label for=m-enblog20180814native-image-using-graalvm-check><a href=/en/blog/2018/08/14/native-image-using-graalvm/ title="Native Image using GraalVM" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180814native-image-using-graalvm><span>Native Image</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180810dubbos-load-balance-li><input type=checkbox id=m-enblog20180810dubbos-load-balance-check>
<label for=m-enblog20180810dubbos-load-balance-check><a href=/en/blog/2018/08/10/dubbos-load-balance/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180810dubbos-load-balance><span>Dubbo's Load Balance</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180807use-annotations-in-dubbo-li><input type=checkbox id=m-enblog20180807use-annotations-in-dubbo-check>
<label for=m-enblog20180807use-annotations-in-dubbo-check><a href=/en/blog/2018/08/07/use-annotations-in-dubbo/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180807use-annotations-in-dubbo><span>Use Annotations In Dubbo</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180807using-zookeeper-in-dubbo-li><input type=checkbox id=m-enblog20180807using-zookeeper-in-dubbo-check>
<label for=m-enblog20180807using-zookeeper-in-dubbo-check><a href=/en/blog/2018/08/07/using-zookeeper-in-dubbo/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180807using-zookeeper-in-dubbo><span>Using Zookeeper in Dubbo</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180807dubbo-101-li><input type=checkbox id=m-enblog20180807dubbo-101-check>
<label for=m-enblog20180807dubbo-101-check><a href=/en/blog/2018/08/07/dubbo-101/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180807dubbo-101><span>Your First Dubbo Demo</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180730the-third-dubbo-meetup-has-been-held-in-shenzhen-li><input type=checkbox id=m-enblog20180730the-third-dubbo-meetup-has-been-held-in-shenzhen-check>
<label for=m-enblog20180730the-third-dubbo-meetup-has-been-held-in-shenzhen-check><a href=/en/blog/2018/07/30/the-third-dubbo-meetup-has-been-held-in-shenzhen/ title="The third Dubbo meetup has been held in Shenzhen" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180730the-third-dubbo-meetup-has-been-held-in-shenzhen><span>The third Dubbo meetup</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180727sentinel-the-flow-sentinel-of-dubbo-services-li><input type=checkbox id=m-enblog20180727sentinel-the-flow-sentinel-of-dubbo-services-check>
<label for=m-enblog20180727sentinel-the-flow-sentinel-of-dubbo-services-check><a href=/en/blog/2018/07/27/sentinel-the-flow-sentinel-of-dubbo-services/ title="Sentinel: The flow sentinel of Dubbo services" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180727sentinel-the-flow-sentinel-of-dubbo-services><span>Introduce sentinel</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180712tracking-with-pinpoint-li><input type=checkbox id=m-enblog20180712tracking-with-pinpoint-check>
<label for=m-enblog20180712tracking-with-pinpoint-check><a href=/en/blog/2018/07/12/tracking-with-pinpoint/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180712tracking-with-pinpoint><span>Tracking with Pinpoint</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180701your-first-dubbo-filter-li><input type=checkbox id=m-enblog20180701your-first-dubbo-filter-check>
<label for=m-enblog20180701your-first-dubbo-filter-check><a href=/en/blog/2018/07/01/your-first-dubbo-filter/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180701your-first-dubbo-filter><span>Your First Dubbo Filter</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180623the-second-dubbo-shanghai-meetup-has-been-held-successfully-li><input type=checkbox id=m-enblog20180623the-second-dubbo-shanghai-meetup-has-been-held-successfully-check>
<label for=m-enblog20180623the-second-dubbo-shanghai-meetup-has-been-held-successfully-check><a href=/en/blog/2018/06/23/the-second-dubbo-shanghai-meetup-has-been-held-successfully/ title="The second Dubbo Shanghai meetup has been held successfully" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180623the-second-dubbo-shanghai-meetup-has-been-held-successfully><span>The second Dubbo meetup</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180512the-first-dubbo-meetup-has-been-held-in-beijing-li><input type=checkbox id=m-enblog20180512the-first-dubbo-meetup-has-been-held-in-beijing-check>
<label for=m-enblog20180512the-first-dubbo-meetup-has-been-held-in-beijing-check><a href=/en/blog/2018/05/12/the-first-dubbo-meetup-has-been-held-in-beijing/ title="The first Dubbo meetup has been held in Beijing" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180512the-first-dubbo-meetup-has-been-held-in-beijing><span>The first Dubbo meetup</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180502the-apachecon-na-schedule-has-been-announced-li><input type=checkbox id=m-enblog20180502the-apachecon-na-schedule-has-been-announced-check>
<label for=m-enblog20180502the-apachecon-na-schedule-has-been-announced-check><a href=/en/blog/2018/05/02/the-apachecon-na-schedule-has-been-announced/ title="The ApacheCon NA schedule has been announced" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180502the-apachecon-na-schedule-has-been-announced><span>ApacheCon NA</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180425the-gsocgoogle-summer-of-code-2018-li><input type=checkbox id=m-enblog20180425the-gsocgoogle-summer-of-code-2018-check>
<label for=m-enblog20180425the-gsocgoogle-summer-of-code-2018-check><a href=/en/blog/2018/04/25/the-gsocgoogle-summer-of-code-2018/ title="The GSoC(Google Summer of Code) 2018" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180425the-gsocgoogle-summer-of-code-2018><span>GSoC 2018</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20180422dubbo-roadmap-is-announced-in-qcon-beijing-2018-li><input type=checkbox id=m-enblog20180422dubbo-roadmap-is-announced-in-qcon-beijing-2018-check>
<label for=m-enblog20180422dubbo-roadmap-is-announced-in-qcon-beijing-2018-check><a href=/en/blog/2018/04/22/dubbo-roadmap-is-announced-in-qcon-beijing-2018/ title="Dubbo roadmap is announced in QCon Beijing 2018" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20180422dubbo-roadmap-is-announced-in-qcon-beijing-2018><span>QCon Beijing 2018</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-enblogproposals-li><input type=checkbox id=m-enblogproposals-check>
<label for=m-enblogproposals-check><a href=/en/blog/proposals/ title="Proposals About Apache Dubbo" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-enblogproposals><span>Proposals</span></a></label><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog10101application-level-service-discovery-li><input type=checkbox id=m-enblog10101application-level-service-discovery-check>
<label for=m-enblog10101application-level-service-discovery-check><a href=/en/blog/1/01/01/application-level-service-discovery/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog10101application-level-service-discovery><span>Application-Level Service Discovery</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog10101enhanced-http-standard-capabilities-of-triple-protocol-li><input type=checkbox id=m-enblog10101enhanced-http-standard-capabilities-of-triple-protocol-check>
<label for=m-enblog10101enhanced-http-standard-capabilities-of-triple-protocol-check><a href=/en/blog/1/01/01/enhanced-http-standard-capabilities-of-triple-protocol/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog10101enhanced-http-standard-capabilities-of-triple-protocol><span>Enhanced HTTP Standard Capabilities of Triple Protocol</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-enblogreleases-li><input type=checkbox id=m-enblogreleases-check>
<label for=m-enblogreleases-check><a href=/en/blog/releases/ title="New Releases" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-enblogreleases><span>Releases</span></a></label><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog202109202714-release-note-li><input type=checkbox id=m-enblog202109202714-release-note-check>
<label for=m-enblog202109202714-release-note-check><a href=/en/blog/2021/09/20/2.7.14-release-note/ title="2.7.14 Release Note" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog202109202714-release-note><span>2.7.14</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog202108233021-release-note-li><input type=checkbox id=m-enblog202108233021-release-note-check>
<label for=m-enblog202108233021-release-note-check><a href=/en/blog/2021/08/23/3.0.2.1-release-note/ title="3.0.2.1 Release Note" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog202108233021-release-note><span>3.0.2.1</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20210818302-release-note-li><input type=checkbox id=m-enblog20210818302-release-note-check>
<label for=m-enblog20210818302-release-note-check><a href=/en/blog/2021/08/18/3.0.2-release-note/ title="3.0.2 Release Note" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20210818302-release-note><span>3.0.2</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20210702301-release-note-li><input type=checkbox id=m-enblog20210702301-release-note-check>
<label for=m-enblog20210702301-release-note-check><a href=/en/blog/2021/07/02/3.0.1-release-note/ title="3.0.1 Release Note" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20210702301-release-note><span>3.0.1</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-enblog20200518past-releases-li><input type=checkbox id=m-enblog20200518past-releases-check>
<label for=m-enblog20200518past-releases-check><a href=/en/blog/2020/05/18/past-releases/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-enblog20200518past-releases><span>Past Releases</span></a></label></li></ul></li></ul></li></ul></nav></div></div><main class="col-12 col-md-9 col-xl-8 pl-md-5" role=main><nav aria-label=breadcrumb class=td-breadcrumbs><ol class=breadcrumb><li class=breadcrumb-item><a href=https://cn.dubbo.apache.org/en/blog/>Blog</a></li><li class=breadcrumb-item><a href=https://cn.dubbo.apache.org/en/blog/news/>Articles</a></li><li class="breadcrumb-item active" aria-current=page><a href=https://cn.dubbo.apache.org/en/blog/2022/05/04/how-to-proxy-dubbo-service-in-apache-shenyu-gateway/ aria-disabled=true class="btn-link disabled">How to proxy Dubbo service in Apache ShenYu Gateway</a></li></ol></nav><section id=deprecation-warning><div class="content deprecation-warning pageinfo outdated-blog"><p>This article is more than one year old. Older articles may contain outdated content. Check that the information in the page has not become incorrect since its publication.</p></div></section><div class=td-content><h1>How to proxy Dubbo service in Apache ShenYu Gateway</h1><div class=lead>This article describes how to access the <code>Dubbo</code> service through the <code>Apache ShenYu</code> gateway. The main content includes a simple example to core call flow analysis and a summary of the design principles.</div><div class="td-byline mb-4"><time datetime=2022-05-04 class=text-muted>Wednesday, May 04, 2022</time></div><header class=article-meta></header><p><img src=/imgs/blog/shenyu-dubbo/ApacheShenYu-Dubbo-en.png alt=img></p><h2 id=1-introduction>1. Introduction</h2><ul><li>Apache ShenYu</li></ul><p><img src=/imgs/blog/shenyu-dubbo/shenyu.png alt=img></p><p><a href=https://shenyu.apache.org/docs/index>Apache ShenYu(Incubating)</a> is an asynchronous, high-performance, cross-language, responsive <code>API</code> gateway. Compatible with a variety of mainstream framework systems, support for hot-plugging, users can customize the development to meet the current and future needs of users in a variety of scenarios, experienced large-scale scenarios hammered.</p><p>In May 2021, <code>ShenYu</code> was donated to the <code>Apache</code> Software Foundation, and the Apache Foundation voted unanimously to enter the incubator.</p><ul><li>Apache Dubbo</li></ul><p><code>Apache Dubbo</code> is a microservice development framework that provides two key capabilities, <code>RPC</code> communication and microservice governance. This means that microservices developed with <code>Dubbo</code> will have the ability to discover and communicate with each other remotely, and take advantage of the rich service governance capabilities provided by Dubbo to achieve service governance requirements such as service discovery, load balancing, traffic scheduling, and so on. At the same time <code>Dubbo</code> is highly scalable, users can customize their own implementation at almost any point to change the default behavior of the framework to meet their business needs.</p><h2 id=2-quick-start-with-dubbo>2. Quick Start with Dubbo</h2><p>This section describes how to connect the <code>Dubbo</code> service to the <code>Shenyu</code> gateway. You can find the [sample code] for this section directly under the project (<a href=https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-dubbo>https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-dubbo</a> -examples-dubbo/shenyu-examples-apache-dubbo-service).</p><h3 id=21-start-shenyu-admin>2.1 Start shenyu-admin</h3><p><code>shenyu-admin</code> is the <code>Apache ShenYu</code> backend management system, there are various ways to start it, this article is started by <code>[local deployment](https://shenyu.apache.org/docs/deployment/deployment-local)</code> way. After successful startup, you need to set the <code>dubbo</code> plugin to be on and set your registered address in the base configuration <code>-></code>Plugin Management&rsquo;, please make sure the registration center has been opened.</p><p><img src=/imgs/blog/shenyu-dubbo/dubbo-enable-en.png alt=img></p><h3 id=22-start-shenyu-gateway>2.2 Start ShenYu Gateway</h3><p>Here it is started by way of <a href=https://github.com/apache/incubator-shenyu/tree/master/shenyu-bootstrap>source</a> and runs directly <code>shenyu-bootstrap</code> in <code>shenyu-bootstrap</code>. ShenyuBootstrapApplication`.</p><p>Make sure the gateway has introduced the relevant dependencies before starting. If the client is <code>apache dubbo</code> and the registry uses <code>zookeeper</code>, please refer to the following configuration.</p><div class=highlight><pre tabindex=0 style=color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java><span style=display:flex><span> <span style=color:#719e07>&lt;!--</span> apache shenyu apache dubbo plugin start<span style=color:#719e07>--&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>groupId<span style=color:#719e07>&gt;</span>org.apache.shenyu<span style=color:#719e07>&lt;/</span>groupId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>artifactId<span style=color:#719e07>&gt;</span>shenyu<span style=color:#719e07>-</span>spring<span style=color:#719e07>-</span>boot<span style=color:#719e07>-</span>starter<span style=color:#719e07>-</span>plugin<span style=color:#719e07>-</span>apache<span style=color:#719e07>-</span>dubbo<span style=color:#719e07>&lt;/</span>artifactId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>version<span style=color:#719e07>&gt;</span>${project.version}<span style=color:#719e07>&lt;/</span>version<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>groupId<span style=color:#719e07>&gt;</span>org.apache.dubbo<span style=color:#719e07>&lt;/</span>groupId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>artifactId<span style=color:#719e07>&gt;</span>dubbo<span style=color:#719e07>&lt;/</span>artifactId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>version<span style=color:#719e07>&gt;</span>2.7.5<span style=color:#719e07>&lt;/</span>version<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;!--</span> Dubbo zookeeper registry dependency start <span style=color:#719e07>--&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>groupId<span style=color:#719e07>&gt;</span>org.apache.curator<span style=color:#719e07>&lt;/</span>groupId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>artifactId<span style=color:#719e07>&gt;</span>curator<span style=color:#719e07>-</span>client<span style=color:#719e07>&lt;/</span>artifactId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>version<span style=color:#719e07>&gt;</span>4.0.1<span style=color:#719e07>&lt;/</span>version<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>exclusions<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>exclusion<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>artifactId<span style=color:#719e07>&gt;</span>log4j<span style=color:#719e07>&lt;/</span>artifactId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>groupId<span style=color:#719e07>&gt;</span>log4j<span style=color:#719e07>&lt;/</span>groupId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>exclusion<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>exclusions<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>groupId<span style=color:#719e07>&gt;</span>org.apache.curator<span style=color:#719e07>&lt;/</span>groupId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>artifactId<span style=color:#719e07>&gt;</span>curator<span style=color:#719e07>-</span>framework<span style=color:#719e07>&lt;/</span>artifactId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>version<span style=color:#719e07>&gt;</span>4.0.1<span style=color:#719e07>&lt;/</span>version<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>groupId<span style=color:#719e07>&gt;</span>org.apache.curator<span style=color:#719e07>&lt;/</span>groupId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>artifactId<span style=color:#719e07>&gt;</span>curator<span style=color:#719e07>-</span>recipes<span style=color:#719e07>&lt;/</span>artifactId<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;</span>version<span style=color:#719e07>&gt;</span>4.0.1<span style=color:#719e07>&lt;/</span>version<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;/</span>dependency<span style=color:#719e07>&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;!--</span> Dubbo zookeeper registry dependency end <span style=color:#719e07>--&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#719e07>&lt;!--</span> apache dubbo plugin end<span style=color:#719e07>--&gt;</span>
</span></span></code></pre></div><h3 id=23-start-shenyu-examples-dubbo>2.3 Start shenyu-examples-dubbo</h3><p>Take the example provided on the official website <a href=https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-dubbo>shenyu-examples-dubbo</a>. Suppose the <code>dubbo</code> service is defined as follows.</p><div class=highlight><pre tabindex=0 style=color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml><span style=display:flex><span><span style=color:#268bd2>&lt;beans</span> /* ...... * <span style=color:#268bd2>/&gt;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>&lt;dubbo:application</span> name=<span style=color:#2aa198>&#34;test-dubbo-service&#34;</span><span style=color:#268bd2>/&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>&lt;dubbo:registry</span> address=<span style=color:#2aa198>&#34;${dubbo.registry.address}&#34;</span><span style=color:#268bd2>/&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>&lt;dubbo:protocol</span> name=<span style=color:#2aa198>&#34;dubbo&#34;</span> port=<span style=color:#2aa198>&#34;20888&#34;</span><span style=color:#268bd2>/&gt;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>&lt;dubbo:service</span> timeout=<span style=color:#2aa198>&#34;10000&#34;</span> interface=<span style=color:#2aa198>&#34;org.apache.shenyu.examples.dubbo.api.service.DubboTestService&#34;</span> ref=<span style=color:#2aa198>&#34;dubboTestService&#34;</span><span style=color:#268bd2>/&gt;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#268bd2>&lt;/beans&gt;</span>
</span></span></code></pre></div><p>Declare the application service name, register the center address, use the <code>dubbo</code> protocol, declare the service interface, and the corresponding interface implementation class.</p><div class=highlight><pre tabindex=0 style=color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java><span style=display:flex><span><span style=color:#586e75>/**
</span></span></span><span style=display:flex><span><span style=color:#586e75> * DubboTestServiceImpl.
</span></span></span><span style=display:flex><span><span style=color:#586e75> */</span>
</span></span><span style=display:flex><span><span style=color:#268bd2>@Service</span>(<span style=color:#2aa198>&#34;dubboTestService&#34;</span>)
</span></span><span style=display:flex><span><span style=color:#268bd2>public</span> <span style=color:#268bd2>class</span> <span style=color:#268bd2>DubboTestServiceImpl</span> <span style=color:#268bd2>implements</span> DubboTestService {
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>@Override</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>@ShenyuDubboClient</span>(path <span style=color:#719e07>=</span> <span style=color:#2aa198>&#34;/findById&#34;</span>, desc <span style=color:#719e07>=</span> <span style=color:#2aa198>&#34;Query by Id&#34;</span>)
</span></span><span style=display:flex><span> <span style=color:#268bd2>public</span> DubboTest <span style=color:#268bd2>findById</span>(<span style=color:#268bd2>final</span> String id) {
</span></span><span style=display:flex><span> <span style=color:#719e07>return</span> <span style=color:#719e07>new</span> DubboTest(id, <span style=color:#2aa198>&#34;hello world shenyu Apache, findById&#34;</span>);
</span></span><span style=display:flex><span> }
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#586e75>//......</span>
</span></span><span style=display:flex><span>}
</span></span></code></pre></div><p>In the interface implementation class, use the annotation <code>@ShenyuDubboClient</code> to register the service with <code>shenyu-admin</code>.</p><p>Configuration information in the configuration file <code>application.yml</code>.</p><div class=highlight><pre tabindex=0 style=color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#268bd2>server</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>port</span>: <span style=color:#2aa198>8011</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>address</span>: <span style=color:#2aa198>0.0.0.0</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>servlet</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>context-path</span>: /
</span></span><span style=display:flex><span><span style=color:#268bd2>spring</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>main</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>allow-bean-definition-overriding</span>: <span style=color:#cb4b16>true</span>
</span></span><span style=display:flex><span><span style=color:#268bd2>dubbo</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>registry</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>address</span>: zookeeper://localhost:2181 <span style=color:#586e75># The registry used by dubbo</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#268bd2>shenyu</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>register</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>registerType</span>: http <span style=color:#586e75>#Registration Method</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>serverLists</span>: http://localhost:9095 <span style=color:#586e75>#Registration Address</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>props</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>username</span>: admin
</span></span><span style=display:flex><span> <span style=color:#268bd2>password</span>: <span style=color:#2aa198>123456</span>
</span></span><span style=display:flex><span> <span style=color:#268bd2>client</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>dubbo</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>props</span>:
</span></span><span style=display:flex><span> <span style=color:#268bd2>contextPath</span>: /dubbo
</span></span><span style=display:flex><span> <span style=color:#268bd2>appName</span>: dubbo
</span></span></code></pre></div><p>In the configuration file, declare the registry address used by <code>dubbo</code>. The <code>dubbo</code> service registers with <code>shenyu-admin</code>, using the method <code>http</code>, and the registration address is <code>http://localhost:9095</code>.</p><p>See <code>[Application Client Access](https://shenyu.apache.org/docs/design/register-center-design/)</code> for more information on the use of the registration method.</p><h3 id=24-invoke-the-dubbo-service>2.4 Invoke the Dubbo service</h3><p>The <code>shenyu-examples-dubbo</code> project will automatically register the interface methods annotated with <code>@ShenyuDubboClient</code> to the gateway after it is successfully started.</p><p>Open <code>Plugins List -> Proxy -> dubbo</code> to see the list of plugin rules configuration.</p><p><img src=/imgs/blog/shenyu-dubbo/dubbo-service-list-en.png alt=img></p><p>Information on the selectors for successful registration.</p><p><img src=/imgs/blog/shenyu-dubbo/dubbo-selector-en.png alt=img></p><p>Information on the rules for successful registration.</p><p><img src=/imgs/blog/shenyu-dubbo/dubbo-rule-en.png alt=img></p><blockquote><p>Selectors and rules are the soul of the <code>Apache ShenYu</code> gateway. Mastering it well, you can manage any traffic. Corresponding to the matching conditions (conditions) inside the selectors and rules, we can handle various complex scenarios according to different traffic filtering rules. Traffic filtering can get data from <code>Header</code>, <code>URI</code>, <code>Query</code>, <code>Cookie</code> and so on Http requests.</p><p>Then you can use <code>Match</code>, <code>=</code>, <code>Regex</code>, <code>Groovy</code>, <code>Exclude</code> and other matching methods to match the data you expect. Multi-group match additions can use the <code>And/Or</code> matching strategy.</p><p>See: <code>[Selector and Rule Management](https://shenyu.apache.org/docs/user-guide/admin-usage/selector-and-rule)</code> for details and usage.</p></blockquote><p>Initiate a <code>GET</code> request to invoke the <code>dubbo</code> service through the <code>ShenYu</code> gateway.</p><div class=highlight><pre tabindex=0 style=color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>GET http://localhost:9195/dubbo/findById?id=100
</span></span><span style=display:flex><span>Accept: application/json
</span></span></code></pre></div><p>After a successful response, the result is as follows.</p><div class=highlight><pre tabindex=0 style=color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>{
</span></span><span style=display:flex><span> &#34;name&#34;: &#34;hello world shenyu Apache, findById&#34;,
</span></span><span style=display:flex><span> &#34;id&#34;: &#34;100&#34;
</span></span><span style=display:flex><span>}
</span></span></code></pre></div><p>At this point, you can successfully access the <code>dubbo</code> service via <code>http</code> requests. The <code>ShenYu</code> gateway converts the <code>http</code> protocol to the <code>dubbo</code> protocol via the <code>shenyu-plugin-dubbo</code> module.</p><h2 id=3-understanding-of-dubbo-plugin>3. Understanding of Dubbo plugin</h2><p>During the process of running the above <code>demo</code>, are there any questions about</p><ul><li>How does the <code>dubbo</code> service register with <code>shenyu-admin</code>?</li><li>How does <code>shenyu-admin</code> synchronize data to the <code>ShenYu</code> gateway?</li><li>How does the <code>DubboPlugin</code> convert the <code>http</code> protocol to the <code>dubbo</code> protocol?</li></ul><p>With these questions in mind, let&rsquo;s dive into understanding the <code>dubbo</code> plugin.</p><h3 id=31-application-client-access>3.1 Application Client Access</h3><p>Application client access refers to accessing microservices to the <code>Apache ShenYu</code> gateway, which currently supports access to <code>Http</code>, <code>Dubbo</code>, <code>Spring Cloud</code>, <code>gRPC</code>, <code>Motan</code>, <code>Sofa</code>, <code>Tars</code> and other protocols.</p><p>Accessing application clients to the <code>Apache ShenYu</code> gateway is achieved through the registry, which involves client-side registration and server-side synchronization of data. The registry supports <code>Http</code>, <code>Zookeeper</code>, <code>Etcd</code>, <code>Consul</code> and <code>Nacos</code>. The default is to register by <code>Http</code>.</p><p>Please refer to <code>[Client Access Configuration](https://shenyu.apache.org/docs/user-guide/register-center-access)</code> for client access related configuration.</p><h4 id=311-client-side-registration>3.1.1 Client-side Registration</h4><p><img src=/imgs/blog/shenyu-dubbo/register-client.png alt=img></p><p>Declare the registry client type, such as <code>Http</code> or <code>Zookeeper</code>, in your microservice configuration.
Load and initialize the corresponding registry client using the <code>SPI</code> method when the application starts, and get the service interface information that needs to be registered in it by implementing the post-processor interface related to the <code>Spring Bean</code>, and put the obtained information into the <code>Disruptor</code>.</p><p>The registry client reads the data from <code>Disruptor</code> and registers the interface information to <code>shenyu-admin</code>, where <code>Disruptor</code> plays the role of decoupling data and operations, which is convenient for extension.</p><h4 id=312-server-side-registration>3.1.2 Server-side Registration</h4><p><img src=/imgs/blog/shenyu-dubbo/register-server.png alt=img></p><p>Declare the registry server type, such as <code>Http</code> or <code>Zookeeper</code>, in the <code>shenyu-admin</code> configuration. When <code>shenyu-admin</code> starts, it will read the configuration type, load and initialize the corresponding registry server, and when the registry server receives the interface information registered by <code>shenyu-client</code>, it will put it into <code>Disruptor</code>, and then it will trigger the registration processing logic to update the service interface information and publish the synchronization event.</p><p>The <code>Disruptor</code> plays a role in decoupling data and operation, which is good for extension. It also has a data buffering role if too many registration requests lead to registration exceptions.</p><h3 id=32-data-synchronization-principle>3.2 Data Synchronization Principle</h3><p>Data synchronization refers to the policy used to synchronize data to the <code>Apache ShenYu</code> gateway after the <code>shenyu-admin</code> backend has manipulated the data. The <code>Apache ShenYu</code> gateway currently supports <code>ZooKeeper</code>, <code>WebSocket</code>, <code>Http long polling</code>, <code>Nacos</code>, <code>Etcd</code> and <code>Consul</code> for data synchronization. The default is to synchronize data via <code>WebSocket</code>.</p><p>Please refer to <code>[Data Synchronization Configuration](https://shenyu.apache.org/docs/user-guide/use-data-sync)</code> for the configuration of data synchronization.</p><h4 id=321-the-significance-of-data-synchronization>3.2.1 The Significance of Data Synchronization</h4><p>The gateway is the entry point for traffic requests and plays a very important role in the microservices architecture, and the importance of high availability of the gateway is self-evident. In the process of using the gateway, in order to meet the business requirements, it is often necessary to change the configuration, such as flow control rules, routing rules and so on. Therefore, the dynamic configuration of the gateway is an important factor to ensure the high availability of the gateway.</p><p>The current data synchronization characteristics are as follows.</p><ul><li>All configurations are cached in the <code>Apache ShenYu</code> gateway memory, and each request uses the local cache, which is very fast.</li><li>Users can change any data in the <code>shenyu-admin</code> backend and it will be synchronized to the gateway memory immediately.</li><li>Supports data synchronization of plugins, selectors, rule data, metadata, signature data, etc. for <code>Apache ShenYu</code>.</li><li>All plug-in selectors and rules are dynamically configured and take effect immediately, without restarting the service.</li><li>Data synchronization method supports <code>Zookeeper</code>, <code>Http long polling</code>, <code>Websocket</code>, <code>Nacos</code>, <code>Etcd</code> and <code>Consul</code>.</li></ul><h4 id=322-data-synchronization-principle-analysis>3.2.2 Data Synchronization Principle Analysis</h4><p>The following diagram shows the flow of <code>Apache ShenYu</code> data synchronization. The <code>Apache ShenYu</code> gateway synchronizes configuration data from the configuration service when it starts, and supports push-pull mode to get configuration change information and then update the local cache. Administrators can change user permissions, rules, plugins, traffic configuration in the administration backend (<code>shenyu-admin</code>) and synchronize the changes to the <code>Apache ShenYu</code> gateway via push-pull mode, depending on which synchronization method is used.</p><p><img src=/imgs/blog/shenyu-dubbo/data-sync.png alt=img></p><p>In the original version, the configuration service relied on the <code>Zookeeper</code> implementation, and the management backend <code>pushed</code> the changes to the gateway. Now we can support <code>WebSocket</code>, <code>Http long polling</code>, <code>Zookeeper</code>, <code>Nacos</code>, <code>Etcd</code> and <code>Consul</code>, by setting <code>shenyu.sync.${strategy}</code> in the configuration file to specify the corresponding synchronization strategy, the default is to use <code>webosocket</code> synchronization strategy to achieve second-level data synchronization. However, one thing to note is that the <code>Apache ShenYu</code> gateway and <code>shenyu-admin</code> must use the same synchronization strategy.</p><p>As shown in the figure below, <code>shenyu-admin</code> sends out configuration change notifications through <code>EventPublisher</code> after a user makes a configuration change, and <code>EventDispatcher</code> processes the change notification, and then synchronizes the data according to the configured synchronization policy (<code>http, weboscket, zookeeper, naocs, etcd, consul</code>). etcd, consul`), the configuration is sent to the corresponding event handler.</p><ul><li>If it is a <code>websocket</code> synchronization policy, the changed data will be actively pushed to <code>shenyu-web</code> and there will be a corresponding <code>WebsocketDataHandler</code> processor at the gateway layer to handle the data push from <code>shenyu-admin</code>.</li><li>In case of <code>zookeeper</code> synchronization policy, the change data will be updated to <code>zookeeper</code>, and <code>ZookeeperSyncCache</code> will listen to <code>zookeeper</code> data changes and process them.</li><li>In case of <code>http</code> synchronization policy, the gateway initiates a long polling request with <code>90s</code> timeout by default, if <code>shenyu-admin</code> has no data change, it will block the <code>http</code> request, if there is data change, it will respond with the changed data information, if more than <code>60s</code> there is still no data change, it will respond with empty data, after the gateway layer receives the response After receiving the response, the gateway layer continues to make <code>http</code> requests, repeating the same requests.</li></ul><h3 id=33-process-analysis>3.3 Process Analysis</h3><p>The process analysis shows the service registration process, data synchronization process and service invocation process from the source code perspective.</p><h4 id=331-service-registration-process>3.3.1 Service Registration Process</h4><ul><li>Reading dubbo services</li></ul><p>Use the annotation <code>@ShenyuDubboClient</code> to mark <code>dubbo</code> services that need to be registered to the gateway.</p><p>Annotation scanning is done via the <code>ApacheDubboServiceBeanListener</code>, which implements the <code>ApplicationListener&lt;ContextRefreshedEvent></code> interface and starts executing the event handler method when a context refresh event occurs during the <code>Spring</code> container startup <code>onApplicationEvent()</code>. In the rewritten method logic, the <code>Dubbo</code> service <code>ServiceBean</code> is read, the metadata object and the <code>URI</code> object are constructed and registered with <code>shenyu-admin</code>.</p><p>The specific registration logic is implemented by the registry, please refer to <code>[Client Access Principles](https://shenyu.apache.org/docs/design/register-center-design/)</code> .</p><ul><li>Processing registration information</li></ul><p>The metadata and <code>URI</code> data registered by the client through the registration center are processed at the <code>shenyu-admin</code> end, which is responsible for storing to the database and synchronizing to the <code>shenyu</code> gateway. The client-side registration processing logic of the <code>Dubbo</code> plugin is in the <code>ShenyuClientRegisterDubboServiceImpl</code>. The inheritance relationship is as follows.</p><p><img src=/imgs/blog/shenyu-dubbo/ShenyuClientRegisterDubboServiceImpl.png alt=img></p><ul><li>ShenyuClientRegisterService: client registration service, top-level interface.</li><li>FallbackShenyuClientRegisterService: registration failure, provides retry operation.</li><li>AbstractShenyuClientRegisterServiceImpl: abstract class, implements part of the public registration logic.</li><li>ShenyuClientRegisterDubboServiceImpl: implements the registration of <code>Dubbo</code> plug-ins.</li></ul><p>Registration information including selectors, rules and metadata.</p><p>The overall <code>dubbo</code> service registration process is as follows.</p><p><img src=/imgs/blog/shenyu-dubbo/dubbo-register-en.png alt=img></p><h4 id=332-data-synchronization-process>3.3.2 Data Synchronization Process</h4><ul><li>admin update data</li></ul><p>Suppose in the backend management system, a new selector data is added, the request goes to the <code>createSelector()</code> method in the <code>SelectorController</code> class, which is responsible for verifying the data, adding or updating the data, and returning the result information.</p><p>In the <code>SelectorServiceImpl</code> class, the <code>createOrUpdate()</code> method completes the conversion of the data, saves it to the database, publishes events, and updates the <code>upstream</code>.</p><p>Persistence of data is done in the <code>Service</code> class, i.e. saving data to the database. Publishing the changed data is done by <code>eventPublisher.publishEvent()</code>, the <code>eventPublisher</code> object is an <code>ApplicationEventPublisher</code> class, the fully qualified name of this class is <code>org.springframework. ApplicationEventPublisher</code>, the function of publishing data is exactly what is done through <code>Spring</code> related functions.</p><p>When the event is published, it automatically goes to the <code>onApplicationEvent()</code> method in the <code>DataChangedEventDispatcher</code> class, which handles the event according to the different data types and data synchronization methods.</p><ul><li>Gateway data synchronization</li></ul><p>At startup, the gateway loads different configuration classes and initializes data synchronization-related classes according to the specified data synchronization method.</p><p>After receiving the data, it performs deserialization operation to read the data type and operation type. Different data types have different data processing methods, so there are different implementation classes. But they also have the same processing logic between them, so they can be implemented by template method design pattern. The same logic is put in the <code>handle()</code> method in the abstract class <code>AbstractDataHandler</code>, and the different logic is given to the respective implementation classes.</p><p>Adding a new selector data is a new operation that goes to the <code>SelectorDataHandler.doUpdate()</code> concrete data processing logic.</p><p>In the common plugin data subscriber <code>CommonPluginDataSubscriber</code>, which is responsible for handling all plugin, selector and rule information</p><p>Saves data to the gateway&rsquo;s memory, <code>BaseDataCache</code> is the class that ultimately caches the data, implemented through the singleton pattern. The selector data is then stored in <code>SELECTOR_MAP</code>, a <code>Map</code>. In the subsequent use, the data is also taken from here.</p><p>The above logic is represented in a flowchart as follows.</p><p><img src=/imgs/blog/shenyu-dubbo/data-sync-seq-en.png alt=img></p><h4 id=333-service-invocation-process>3.3.3 Service Invocation Process</h4><p>In the <code>Dubbo</code> plugin system, the class extends relationship is as follows.</p><p><img src=/imgs/blog/shenyu-dubbo/ApacheDubboPlugin.png alt=img></p><blockquote><p>ShenyuPlugin: top-level interface, defining interface methods.</p><p>AbstractShenyuPlugin: abstract class that implements the common logic of the plugin; > AbstractShenyuPlugin: abstract class that implements the common logic of the plugin.</p><p>AbstractDubboPlugin: dubbo plug-in abstract class, implementing <code>dubbo</code> common logic (ShenYu gateway supports ApacheDubbo and AlibabaDubbo).</p><p>ApacheDubboPlugin: ApacheDubbo plugin.</p></blockquote><ul><li>org.apache.shenyu.web.handler.ShenyuWebHandler.DefaultShenyuPluginChain#execute()</li></ul><p>After passing the <code>ShenYu</code> gateway proxy, the request entry is <code>ShenyuWebHandler</code>, which implements the <code>org.springframework.web.server.WebHandler</code> interface and connects all plugins through the chain-of-responsibility design pattern.</p><ul><li>org.apache.shenyu.plugin.base.AbstractShenyuPlugin#execute()</li></ul><p>Determining whether a plugin is executed when a request is made to the gateway is done by the specified matching logic. The matching logic for selectors and rules is executed in the <code>execute()</code> method.</p><ul><li>org.apache.shenyu.plugin.global.GlobalPlugin#execute()</li></ul><p>The first to be executed is the <code>GlobalPlugin</code> , which is a global plugin that constructs contextual information in the <code>execute()</code> method.</p><ul><li>org.apache.shenyu.plugin.base.RpcParamTransformPlugin#execute()</li></ul><p>Next to be executed is the <code>RpcParamTransformPlugin</code>, which is responsible for reading the parameters from the <code>http</code> request, saving them in the <code>exchange</code> and passing them to the <code>rpc</code> service. In the <code>execute()</code> method, the core logic of the plugin is executed: it gets the request information from <code>exchange</code> and processes the parameters according to the form of the content passed in the request.</p><ul><li>org.apache.shenyu.plugin.dubbo.common.AbstractDubboPlugin</li></ul><p>Then what gets executed is the <code>DubboPlugin</code> . In the <code>doExecute()</code> method, the main focus is on checking metadata and parameters. In the <code>doDubboInvoker()</code> method, special context information is set and then the generalized invocation of <code>dubbo</code> is started.</p><p>In the <code>genericInvoker()</code> method.</p><ul><li>Gets the <code>ReferenceConfig</code> object.</li><li>obtains the generalization service <code>GenericService</code> object.</li><li>Constructs the request parameter <code>pair</code> object.</li><li>Initiate an asynchronous generalization invocation.</li></ul><p>The generalization call enables you to call the <code>dubbo</code> service at the gateway.</p><p>The <code>ReferenceConfig</code> object is the key object that supports generalization calls, and its initialization is done during data synchronization.</p><ul><li>org.apache.shenyu.plugin.response.ResponsePlugin#execute()</li></ul><p>The last one to be executed is <code>ResponsePlugin</code>, which unifies the response result messages of the gateway. The processing type is determined by the <code>MessageWriter</code>, and the class extends relationship is as follows.</p><p><img src=/imgs/blog/shenyu-dubbo/MessageWriter.png alt=img></p><blockquote><p>MessageWriter: interface that defines message processing methods.</p><p>NettyClientMessageWriter: Handles the results of <code>Netty</code> calls.</p><p>RPCMessageWriter: processing the results of <code>RPC</code> calls.</p><p>WebClientMessageWriter: processing the results of <code>WebClient</code> calls;</p></blockquote><p>The <code>Dubbo</code> service is called and the result of processing is the <code>RPCMessageWriter</code>.</p><ul><li>org.apache.shenyu.plugin.response.strategy.RPCMessageWriter#writeWith()</li></ul><p>Process the response results in the <code>writeWith()</code> method, get the results or handle exceptions.</p><p>At this point in the analysis, the source code analysis of the <code>Dubbo</code> plugin is complete, and the analysis flowchart is as follows.</p><p><img src=/imgs/blog/shenyu-dubbo/dubbo-execute-en.png alt=img></p><h2 id=4-summary>4. Summary</h2><p>This article analyzes the proxy process of <code>ShenYu</code> gateway to Dubbo service from a practical case. The main knowledge points involved are as follows.</p><ul><li>Implementing plug-ins through the chain-of-responsibility design pattern.</li><li>implementing <code>AbstractShenyuPlugin</code> using the template method design pattern to handle generic operation types.</li><li>implementation of the cached data class <code>BaseDataCache</code> using the singleton design pattern.</li><li>the ability to introduce different registries and number synchronization methods through the <code>springboot starter</code>, which is very scalable.</li><li>support for hot updates of rules through <code>admin</code> to facilitate traffic control.</li><li><code>Disruptor</code> queue is for data and operation decoupling, as well as data buffering.</li></ul><ul class="list-unstyled d-flex justify-content-between align-items-center mb-0 pt-5"><li><a href=/en/blog/2022/01/18/makes-it-more-convenient-for-you-to-proxy-dubbo-services-in-apache-apisix/ aria-label="Previous - Makes it More Convenient for You to Proxy Dubbo Services in Apache APISIX" class="btn btn-primary"><span class=mr-1>←</span>Previous</a></li><li><a href=/en/blog/2023/04/15/advanced-cloud-native-dubbo-3.2-officially-released/ aria-label="Next - Advanced cloud native - Dubbo 3.2 officially released" class="btn btn-primary">Next<span class=ml-1>β†’</span></a></li></ul></div><div id=pre-footer><h2>Feedback</h2><p class=feedback--prompt>Was this page helpful?</p><button class="btn btn-primary mb-4 feedback--yes">Yes</button>
<button class="btn btn-primary mb-4 feedback--no">No</button></div><script>const yes=document.querySelector(".feedback--yes"),no=document.querySelector(".feedback--no");document.querySelectorAll(".feedback--link").forEach(e=>{e.href=e.href+window.location.pathname});const sendFeedback=e=>{gtag||console.log("!gtag"),gtag("event","click",{event_category:"Helpful",event_label:window.location.pathname,value:e})},disableButtons=()=>{yes.disabled=!0,yes.classList.add("feedback--button__disabled"),no.disabled=!0,no.classList.add("feedback--button__disabled")};yes.addEventListener("click",()=>{sendFeedback(1),disableButtons(),document.querySelector(".feedback--response").classList.remove("feedback--response__hidden")}),no.addEventListener("click",()=>{sendFeedback(0),disableButtons(),document.querySelector(".feedback--response").classList.remove("feedback--response__hidden")})</script></main><div class="d-none d-xl-block col-xl-2 td-toc d-print-none"><div class="td-page-meta ml-2 pb-1 pt-2 mb-0"><a href=https://github.com/apache/dubbo-website/edit/master/content/en/blog/news/how-to-proxy-dubbo-in-apache-shenyu.md target=_blank><i class="fa fa-edit fa-fw"></i> Edit this page</a>
<a href="https://github.com/apache/dubbo-website/new/master/content/en/blog/news/how-to-proxy-dubbo-in-apache-shenyu.md?filename=change-me.md&amp;value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A" target=_blank><i class="fa fa-edit fa-fw"></i> Create child page</a>
<a href="https://github.com/apache/dubbo-website/issues/new?title=How%20to%20proxy%20Dubbo%20service%20in%20Apache%20ShenYu%20Gateway" target=_blank><i class="fab fa-github fa-fw"></i> Create an issue</a>
<a href=https://github.com/apache/dubbo/issues/new target=_blank><i class="fas fa-tasks fa-fw"></i> Create project issue</a></div><nav id=TableOfContents><ul><li><a href=#1-introduction>1. Introduction</a></li><li><a href=#2-quick-start-with-dubbo>2. Quick Start with Dubbo</a><ul><li><a href=#21-start-shenyu-admin>2.1 Start shenyu-admin</a></li><li><a href=#22-start-shenyu-gateway>2.2 Start ShenYu Gateway</a></li><li><a href=#23-start-shenyu-examples-dubbo>2.3 Start shenyu-examples-dubbo</a></li><li><a href=#24-invoke-the-dubbo-service>2.4 Invoke the Dubbo service</a></li></ul></li><li><a href=#3-understanding-of-dubbo-plugin>3. Understanding of Dubbo plugin</a><ul><li><a href=#31-application-client-access>3.1 Application Client Access</a></li><li><a href=#32-data-synchronization-principle>3.2 Data Synchronization Principle</a></li><li><a href=#33-process-analysis>3.3 Process Analysis</a></li></ul></li><li><a href=#4-summary>4. Summary</a></li></ul></nav><div class="taxonomy taxonomy-terms-cloud taxo-tags"><h5 class=taxonomy-title>Tags</h5><ul class=taxonomy-terms><li><a class=taxonomy-term href=https://cn.dubbo.apache.org/en/tags/ecosystem/ data-taxonomy-term=ecosystem><span class=taxonomy-label>ecosystem</span><span class=taxonomy-count>1</span></a></li><li><a class=taxonomy-term href=https://cn.dubbo.apache.org/en/tags/news/ data-taxonomy-term=news><span class=taxonomy-label>news</span><span class=taxonomy-count>1</span></a></li><li><a class=taxonomy-term href=https://cn.dubbo.apache.org/en/tags/opentelemetry/ data-taxonomy-term=opentelemetry><span class=taxonomy-label>OpenTelemetry</span><span class=taxonomy-count>1</span></a></li><li><a class=taxonomy-term href=https://cn.dubbo.apache.org/en/tags/tracing/ data-taxonomy-term=tracing><span class=taxonomy-label>tracing</span><span class=taxonomy-count>1</span></a></li></ul></div></div></div></div></div><footer class="bg-dark py-5 row d-print-none footer-margin-0"><div class="container-fluid mx-sm-5"><div class=row><div class="col-6 col-sm-4 text-xs-center order-sm-2"><ul class="list-inline mb-0"><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title="Dubbo mailing list archive" aria-label="Dubbo mailing list archive"><a class=text-white target=_blank rel="noopener noreferrer" href=https://lists.apache.org/list.html?dev@dubbo.apache.org><i class="fa fa-envelope"></i></a></li></ul></div><div class="col-6 col-sm-4 text-right text-xs-center order-sm-3"><ul class="list-inline mb-0"><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=GitHub aria-label=GitHub><a class=text-white target=_blank rel="noopener noreferrer" href=https://github.com/apache/dubbo><i class="fab fa-github"></i></a></li><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title="Subscribe to mailing list" aria-label="Subscribe to mailing list"><a class=text-white target=_blank rel="noopener noreferrer" href=mailto:dev-subscribe@dubbo.apache.org><i class="fa fa-envelope"></i></a></li></ul></div><div class="col-12 col-sm-4 text-center py-2 order-sm-2"><small class=text-white>&copy; 2024 The Apache Software Foundation. Apache and the Apache feather logo are trademarks of The Apache Software Foundation. All Rights Reserved</small></div></div></div></footer><div class="row pt-2 pb-2 footer-margin-0"><div class="container-fluid mx-sm-5"><div class=text-center id=my-footer><img alt=apache_logo src=/imgs/apache_logo.png><ul><li><a href=https://www.apache.org>Foundation</a></li><li><a href=https://www.apache.org/licenses/>License</a></li><li><a href=https://dubbo.apache.org/en/overview/notices/>Security</a></li><li><a href=https://www.apache.org/events/current-event>Events</a></li><li><a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a></li><li><a href=https://privacy.apache.org/policies/privacy-policy-public.html>Privacy</a></li><li><a href=https://www.apache.org/foundation/thanks.html>Thanks</a></li></ul></div></div></div><script src=/js/popper.min.js integrity=sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49 crossorigin=anonymous></script><script src=/js/bootstrap.min.js integrity=sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy crossorigin=anonymous></script><script src=/js/main.min.b075178d232d3b0039b3cb6af2fc2e9d90071820167a60f4eea3a79169975ee8.js integrity="sha256-sHUXjSMtOwA5s8tq8vwunZAHGCAWemD07qOnkWmXXug=" crossorigin=anonymous></script><script async src=https://widget.kapa.ai/kapa-widget.bundle.js data-website-id=d763c4f2-f871-400b-aeca-d986c4af73c2 data-project-name="Apache Dubbo" data-project-color=#E8442E data-button-text="Ask AI" data-search-mode-enabled=true data-modal-open-on-command-k=true data-modal-disclaimer="The AI supports multiple languages, but it may not be accessible in China due to recaptcha, a proxy is required." data-project-logo=https://pbs.twimg.com/profile_images/1011849068283191302/FJbH5vbF_400x400.jpg data-modal-example-questions="What is Apache Dubbo?,How to run Apache Dubbo?" data-button-position-top data-button-position-right=20px data-button-position-bottom=200px data-button-position-left></script><script>(function(e,t,n,s){e[s]=e[s]||[];var a=t.getElementsByTagName(n)[0],i=t.createElement(n);i.async=!0,i.id="beacon-aplus",i.setAttribute("exparams","userid=&aplus&sidx=aplusSidex&ckx=aplusCkx"),i.src="//g.alicdn.com/alilog/mlog/aplus_v2.js",i.crossorigin="anonymous",a.parentNode.insertBefore(i,a)})(window,document,"script","aplus_queue"),function(e){var t=e.createElement("script");t.type="text/javascript",t.async=!0,t.src="//g.alicdn.com/aes/??tracker/3.3.4/index.js,tracker-plugin-pv/3.0.5/index.js,tracker-plugin-event/3.0.0/index.js,tracker-plugin-autolog/3.0.3/index.js,tracker-plugin-survey/3.0.3/index.js,tracker-plugin-jserror/3.0.3/index.js,tracker-plugin-resourceError/3.0.3/index.js",t.onload=function(){window.AES_CONFIG=window.AES_CONFIG||{env:"prod"},window.aes=new AES({pid:"zN245h",user_type:6}),window.AESPluginAutologConfig={exposure:"auto"},window.AEMPluginInstances=[aes.use(AESPluginPV,window.AESPluginPVConfig||{enableHistory:!0}),aes.use(AESPluginEvent,window.AESPluginEventConfig||{}),aes.use(AESPluginSurvey,window.AESPluginEventConfig||{}),aes.use(AESPluginAutolog,window.AESPluginAutologConfig||{}),aes.use(AESPluginJSError,window.AESPluginJSError||{}),aes.use(AESPluginResourceError,window.AESPluginResourceError||{})]},setTimeout(function(){e.getElementsByTagName("body")[0].appendChild(t)},800)}(document)</script></body></html>