You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/11/24 12:20:18 UTC

[GitHub] [apisix] Jimy-Guo opened a new issue, #8396: 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?

Jimy-Guo opened a new issue, #8396:
URL: https://github.com/apache/apisix/issues/8396

   ### 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](apisix:2.15.1-centos)):
   - 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
   }`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org