FeignException ServiceUnavailable:负载均衡器不包含服务匹配结果服务的实例

问题描述

我无法理解,也找不到关于如何修复主题中的异常的任何解释。

这是我使用的主要代码

尤里卡服务器

申请:

...
@SpringBootApplication
@EnableEurekaServer
public class BbSimApplication {

    public static void main(String[] args) {
        SpringApplication.run(BbSimApplication.class,args);
    }
}

application.yml:

server.port : 8088

spring: 
    application: 
        name : bbsim-discovery-server

eureka:
    server:
        evictionIntervalTimerInMs: 3000
        response-cache-update-interval-ms: 3000
        wait-time-in-ms-when-sync-empty: 0
        peer-node-read-timeout-ms : 10000
    client:
        registerWithEureka: false
        fetchRegistry: false
        service-url: 
            defaultZone: http://localhost:${server.port}/eureka

控制器类:

@RestController
public class WebController {

    @Autowired private WebService webService;

    @GetMapping("/matchresultbyids")
    public MatchStats matchResult(@RequestParam Long homeId,@RequestParam Long awayId){

        return webService.matchResult(homeId,awayId);
    }
}

经理服务

申请:

@SpringBootApplication
@EnableFeignClients
@EnablediscoveryClient
public class BBSimManagerServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(BBSimManagerServiceApplication.class,args);
    }
}

application.yaml:

server.port: 9903

spring:
    application.name: bbsim-manager-service
eureka:
    client:
        serviceUrl:
            defaultZone: ${EUREKA_URI:http://localhost:8088/eureka}
            registryFetchIntervalSeconds: 1
            # register-with-eureka: true
            # fetch-registry: true
    instance:
        leaserenewalIntervalInSeconds: 1

客户端界面:

@FeignClient("match-result-service")
public interface MatchResultClient {

    @GetMapping("/matchresultbyids")
    MatchStats getMatchResult();
}

控制器类:

@RestController
public class BbsimManagerController {
    
    @Autowired
    MatchResultClient matchStatsClient;
 
    @GetMapping("/matchresultbyids")
    public MatchStats matchResult(){

        return matchStatsClient.getMatchResult();
    }
}

匹配结果服务

申请:

@SpringBootApplication
@EnablediscoveryClient
public class MatchResultServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(MatchResultServiceApplication.class,args);
    }

}

application.yml:

server.port: 9901

spring:
    application:
        name: match-result-service
eureka:
    client:
        serviceUrl:
            defaultZone: http://localhost:8088/eureka/
            registryFetchIntervalSeconds: 1
            instance:
                leaserenewalIntervalInSeconds: 1

控制器:

@RestController
public class WebController {

    @Autowired private WebService webService;

    @GetMapping("/matchresultbyids")
    public MatchStats matchResult(){

        return webService.matchResult();
    }
}

enter image description here

当我尝试执行时:

http://localhost:9903/matchresultbyids

我得到了例外:

o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing Failed; nested exception is feign.FeignException$ServiceUnavailable: [503] during [GET] to [http://match-result-service/matchresultbyids?homeId=0&awayId=1] [MatchResultClient#getMatchResult()]: [Load balancer does not contain an instance for the service match-result-service]] with root cause

feign.FeignException$ServiceUnavailable: [503] during [GET] to [http://match-result-service/matchresultbyids?homeId=0&awayId=1] [MatchResultClient#getMatchResult()]: [Load balancer does not contain an instance for the service match-result-service]

你能告诉我哪里出了问题以及如何解决吗?

谢谢大家。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)