GithubHelp home page GithubHelp logo

apisix-dubbo-nacos's Introduction

APISIX-Dubbo-Nacos

APISIX-Dubbo-Nacos Demo

在使用此demo前,需要安装 DockerDocker Compose ;并确保有java运行环境。

启动APISIX以及Nacos

    git clone https://github.com/KomachiSion/APISIX-Dubbo-Nacos.git
    cd APISIX-Dubbo-Nacos/demo/docker
    docker-compose -p docker-apisix-dubbo-nacos up -d

等待所有容器启动后,通过telnet或curl命令检查:

    telnet 127.0.0.1 9080
    telnet 127.0.0.1 8848

启动 dubbo 样例

    cd APISIX-Dubbo-Nacos/demo/dubbo-samples-nacos-registry-1.0
    bin/startup.sh
    tail -f logs/stdout.log

等待 dubbo service started 字样出现。

浏览器登陆Nacos控制台 127.0.0.1:8848/nacos 默认用户名密码为nacos, nacos

可以看到dubbo服务已经注册到nacos中。

APISIX 设置 upstream及route规则

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
    "uri": "/dubbo/nacos",
    "upstream": {
        "service_name": "providers:org.apache.dubbo.samples.api.ApisixService:1.0.0:",
        "type": "roundrobin",
        "discovery_type": "nacos"
    },
    "plugins": {
        "dubbo-proxy": {
            "service_name": "org.apache.dubbo.samples.api.ApisixService",
            "service_version": "1.0.0",
            "method": "apisixDubbo"
        }
    }
}'

返回 HTTP/1.1 201 Created 则证明创建成功

同时可以用 curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' 查看该规则。

通过APISIX 调用dubbo服务

使用curl -v http://127.0.0.1:9080/dubbo/nacos -H "Host: example.org" -X POST --data '{"name": "hello"}' 进行测试调用, 返回dubbo success 即为调用成功。

同时可以在 dubbo样例的日志logs/stdout.log 中看到打印出来的http headers和内容参数。

apisix-dubbo-nacos's People

Contributors

komachision avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.