0

I have two micro-services(car-management-service & rent-management-service), in rent-management-service i'm calling car-management-service through Ribbon& FeignClient with the help of Eureka Discovery Server. And it's working perfectly.

I have started three instances of car-management-service running on port (8100,8101,8102), and Eureka provide these three instances perfectly one after the other.

Now I want to try is it possible to limit this to call only two of these instances by disabling (Temporary- just to Test is it possible) Eureka and providing direct urls of the car-management-service instances while still keeping Ribbon & FeignClient.

Portion of the application.yml of rent-management-service

eureka:
  client:
    service-url:
      defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
car-management-service:
  ribbon:
    eureka:
      enabled: false
    listOfServers: localhost:8100, localhost:8101
    #listOfServers: localhost:8100, localhost:8101, localhost:8102
    ServerListRefreshInterval: 1000

Portion of the application.yml of car-management-service

server:
  port: 8100
eureka:
  client:
    enabled: true
    service-url:
      defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}  

Even though I have disabled Eureka in rent-management-service for discover car-management-service instances and hardcoded two of the three running car-management-service instances, rent-management-service still picks up all the three instances.

Why is it happening? Is there wrong with application.yml configuration or rent-management-service still picks up all the three car-management-service instances because they have the Eureka server dependency in pom.xml?

Hasan Can Saral
  • 2,950
  • 5
  • 43
  • 78
Akila Supun
  • 21
  • 3
  • 8
  • In rent-managment-service try use-> ribbon.eureka.enabled: false instead car-management-service.ribbon.eureka.enabled: false – David Araujo Nov 04 '19 at 12:51
  • @DavidAraujo if I do so, doesn't it disable the use of Eureka Service support in entire rent-managment-service? Including all the other services (except ***car-management-service***) used in rent-service with the help of Feign&Ribbon? I want to limit/hardcode two instances only for the ***car-management-service*** – Akila Supun Nov 04 '19 at 14:31

1 Answers1

1

if I understand right you want 3rd instance from your car-management-service not to get traffic from discovery service. isn't it? you run 3 instances but you want to keep one away from eureka? you can do this. run 2 instances from car-management-service and in 3rd instance add bellow property

eureka:
  client:
    fetch-registry: false
    register-with-eureka: false

in this case that 3rd service will not register with eureka.

  • Thank you @krishantha-dinesh, that solves the question between the ***car-management-service & rent-management-service*** but doing so third instance becomes obsolete, right? no other services also can't use the third instance of ***car-management-service***. I seeking a way to disable eureka's help and hardcode 2 instances of ***car-management-service*** used with ***rent-management-service***, but all three instance will still be used by services other than the ***rent-management-service***. – Akila Supun Nov 07 '19 at 03:07