apisix-java-plugin-runner icon indicating copy to clipboard operation
apisix-java-plugin-runner copied to clipboard

help request:i want to build a apisix with apisix-seed(zookeeper with dubbo) ,but dubbo-proxy asked for Map response and dubbo-providers are too much.Can i use springboot+zk+dubbo in apisix-java-plugin-runner for it?

Open Jimy-Guo opened this issue 3 years ago • 1 comments

Description

之前用的用的apisix+dubbo-proxy+apisix-seed(zookeeper+dubbo)得的结构来做dubbo转http的哇,修改apisix-seed的源代码能够获取到对应的IP和port但是配置完之后dubbo-proxy需要dubbo方添加一个使用的是MAP结构服务 ,dubbo服务方太多,未添加,导致调用响应499,未想出好的方案,故此想问一下自定义apisix-java-plugin-runner里面可以连接zk吗?从filter里面调用对应的服务进行返回数据可以吗?

Environment

  • APISIX version (2.15):
  • Operating system (Linux:
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run docker.io/bitnami/etcd:3.4.16-debian-10-r14):
  • apisix-seed源码:其中为适配dubbo-proxy修改了discoverer/zookeeper.go: // fetchService fetch service watch and send message notify func (zd *ZookeeperDiscoverer) fetchService(serviceName string, a6conf map[string]*message.Message) error { var service *ZookeeperService zkService, ok := zd.zkWatchServices.Load(serviceName) log.Info("start get service: %s ", serviceName) if ok { service = zkService.(*ZookeeperService) } else { var err error service, err = zd.newZookeeperClient(serviceName) if err != nil { log.Errorf("zd.newZookeeperClient fail: %s ,err: %s ", serviceName, err) return err } zd.addWatchService(service) } service.mutex.Lock() for k, msg := range a6conf { if _, ok = service.BindEntities[k]; !ok { service.BindEntities[k] = msg } else { service.BindEntities[k].Version = msg.Version } } service.mutex.Unlock() var path = service.WatchPath+"/providers" children, _, err := zd.zkConn.Children(path) if err != nil { log.Errorf("zd.zkConn.Children fail: %s ,err: %s ", path, err) return err } var nodes []*message.Node for _, p := range children { tmp := path + "/" + p fmt.Println("---first tmp: ", p) serviceInfo, _, err := zd.zkConn.Get(tmp) if err != nil { fmt.Println("zd.zkConn.Get fail: %s ,err: %s ", tmp, err) return err } ip :=string(serviceInfo) if len(ip) ==0{ fmt.Println("serviceInfo is null ") continue } ipStr :=ip+"%3A" fmt.Println("----zd.zkConn.Get success:", ipStr, len(ipStr)) targetPort :=p[(strings.Index(p, ipStr)+len(ipStr)):strings.Index(p, "%2F"+service.Name)] port, err := strconv.Atoi(targetPort) if err != nil { log.Errorf("strconv.Atoi fail: %s ,err: %s ", targetPort, err) return err } fmt.Println(port) dubboNode := &message.Node{ Host: ip, Port: port, Weight: 100, } nodes=append(nodes,dubboNode) } zd.sendMessage(service, nodes) return nil }

Jimy-Guo avatar Nov 24 '22 12:11 Jimy-Guo

故此想问一下自定义apisix-java-plugin-runner里面可以连接zk吗?从filter里面调用对应的服务进行返回数据可以吗?

Have not tried, I think it should be possible, you need to try yourself.

tzssangglass avatar Nov 25 '22 03:11 tzssangglass