Introduction to Dubbo HttpFilter

Introduction to Dubbo HttpFilter

Using HTTP to Call Dubbo

Define Pixiu Configuration File

  1. static_resources:
  2. listeners:
  3. - name: "http-listener"
  4. protocol_type: "HTTP"
  5. address:
  6. socket_address:
  7. address: "0.0.0.0"
  8. port: 8888
  9. filter_chains:
  10. filters:
  11. - name: dgp.filter.httpconnectionmanager
  12. config:
  13. route_config:
  14. routes:
  15. - match:
  16. prefix: "*"
  17. http_filters:
  18. - name: dgp.filter.http.dubboproxy
  19. config:
  20. dubboProxyConfig:
  21. auto_resolve: true
  22. registries:
  23. "zookeeper":
  24. protocol: "zookeeper"
  25. timeout: "3s"
  26. address: "127.0.0.1:2181"
  27. username: ""
  28. password: ""
  29. timeout_config:
  30. connect_timeout: 5s
  31. request_timeout: 5s
  32. clusters:
  33. - name: "dubbo-server"
  34. lb_policy: "lb"
  35. endpoints:
  36. - id: 1
  37. socket_address:
  38. address: 127.0.0.1
  39. port: 20000
  40. shutdown_config:
  41. timeout: "60s"
  42. step_timeout: "10s"
  43. reject_policy: "immediacy"

Prepare Dubbo Service

Start zookeeper, ensure docker and compose are prepared in advance. If available locally, this can be ignored.

docker-compose.yml

  1. docker-compose -f {CURRENT_PATH}/dubbo-go-pixiu-samples/dubbohttpproxy/docker/docker-compose.yml && docker-compose up -d

Start Dubbo Server

Run

  1. export DUBBO_GO_CONFIG_PATH={CURRENT_PATH}/dubbo-go-pixiu-samples/dubbohttpproxy/server/dubbo/profiles/dev/server.yml
  2. go run .

Start Pixiu

  1. ./dubbo-go-pixiu gateway start --config {CURRENT_PATH}pixiu/conf.yaml

Use curl for querying and updating

Run the following curl command:

Query

  1. curl http://localhost:8888/UserService/com.dubbogo.pixiu.UserService/GetUserByName -X POST \
  2. -H 'Content-Type: application/json' \
  3. -H 'x-dubbo-http1.1-dubbo-version: 1.0.0' \
  4. -H 'x-dubbo-service-protocol: dubbo' \
  5. -H 'x-dubbo-service-version: 1.0.0' \
  6. -H 'x-dubbo-service-group: test' \
  7. -d '{"types":"string","values":"tc"}'

Update

  1. curl http://localhost:8888/UserService/com.dubbogo.pixiu.UserService/UpdateUserByName -X POST \
  2. -H 'Content-Type: application/json' \
  3. -H 'x-dubbo-http1.1-dubbo-version: 1.0.0' \
  4. -H 'x-dubbo-service-protocol: dubbo' \
  5. -H 'x-dubbo-service-version: 1.0.0' \
  6. -H 'x-dubbo-service-group: test' \
  7. -d '{"types":"string,object","values":["tc",{"id":"0001","code":1,"name":"tc","age":15}]}'

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)