【问题标题】:How to use Apache ZooKeeper with Spring Cloud service discovery and load balancing?如何将 Apache ZooKeeper 与 Spring Cloud 服务发现和负载平衡一起使用?
【发布时间】:2015-09-18 14:48:51
【问题描述】:

我是 Apache ZooKeeper 概念的新手,使用 netflix 功能区客户端实现服务发现和负载平衡。我在 github (https://github.com/spring-cloud/spring-cloud-zookeeper) 中看到了一些示例。谁能帮我知道如何在应用服务实例上设置 ZooKeeper 和服务发现实现。我很想知道这个概念。

提前谢谢..,

【问题讨论】:

  • 你到底需要 Zookeeper 提供什么?如果它唯一的服务发现,那么 eureka 可能会更容易。
  • @Freakman:是的,你是对的。 Eureka 更容易实现服务注册和服务发现。但是,根据要求,我必须使用 ZooKeeper。

标签: java apache-zookeeper spring-cloud service-discovery microservices


【解决方案1】:

今天(in March 2018)你应该使用Zookeeper Dependencies

  • 添加依赖org.springframework.cloud:spring-cloud-starter-zookeeper-discovery;

  • 设置Zookeeper Dependencies

    spring:
        # your app name
        application.name: app
        cloud.zookeeper:
            discovery:
                root: /path/to/your/dependencies
                enabled: true
            dependencies:
                dependencyOne:
                    # absolute path is /path/to/your/dependencies/dependencyOne
                    path: /dependencyOne
                    loadBalancerType: ROUND_ROBIN
                    required: false
                    stubs: org.springframework:foo:stubs
            dependency.resttemplate.enabled: false
    

spring-cloud docs中查看更多信息

【讨论】:

    猜你喜欢
    • 2021-09-06
    • 2019-05-22
    • 2018-06-18
    • 2011-12-03
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-01
    • 2013-03-24
    相关资源
    最近更新 更多