1
votes

Currently, I am working on a POC in my organization. Our goal is to implement Service Discovery. For that reason, I was exploring Eureka. Eureka is pretty great for service discovery without any conditions. Our requirement is to implement conditional service discovery.

Our current implementation: Consumers consuming micro-service

This is a straight-forward implementation where we have multiple clients consuming services exposed by a single micro-service Service-A.

As we are planning to introduce a new micro-service Service-B with the same contract as Service-A. With this new service, clients will have to implement logic to identify which service to call based on some parameters. Each client will have to implement this logic: Multiple service providers

This is where Service Discovery comes in. I was trying out Eureka, but I couldn't find any document or resource which indicated that we can have custom logic for service registry or service discovery. I am not even sure if what I want to do is possible with Eureka. This is our goal: Custom service discovery in Eureka

We want to use Service discovery as we might add few more such services based on new types. What I tried was to have my own RestController which will then call internal methods of ApplicationResource. That did not work. I couldn't find any interface/abstract class that I can implement/extend to change the logic.

*Pardon my bad drawing skills.

1
With Zuul you can do the mapping configuration. That helps you to provide url for service mapping which I assume exactly what you need. So you don't need to extend the discovery or anything. Just map /info/typeA/items to ServiceA and /info/typeB/items to ServiceBcool
Yes... Got that part. I was exploring the wrong component. What we really need is Zuul. I don't see any such scenario where we might need to extend Eureka Discovery, but it would be interesting to know if it has any such provision.Mahesh Shinde

1 Answers

1
votes

Try using Netflix Zuul. This will also register with Eureka server and automatically set up dynamic routing based on other services that are registered with Eureka to provide access to our APIs through one singular point.

I hope this link helps you: https://stackabuse.com/spring-cloud-routing-with-zuul-and-gateway/