How can we discover a service in Eureka using a qualifying property with Spring Cloud and Spring Boot -
we have 50 microservices developed using spring boot. use spring cloud registering services eureka , invoke service consumer using feign. contract pretty standard, consumer uses interface @feignclient("<foo>")
annotation locate service that's registered foo
eureka. registration, lookup , invocation on target service works expected 1 or multiple instances of service running.
we have new requirement same service foo
may running multiple instances each instance has specific stereotype or designation. example, instances of foo
expected deal 3rd party integration synchronous workload, , instances of foo
expected deal internal messages (asynchronous workload). have defined configuration property called stereotype
in service defined @ bootstrap (done via part of spring cloud config) tell service instance deal sync
or async
workloads. configuration looks this:
service.stereotype: sync # or async
in addition, add property eureka's eureka.instance.metadatamap
map stereotype
property when registering service foo
. can see eureka displays value service foo
when gets registered.
so far good. question:
is there configuration (or annotation) mechanism in either discoveryclient
or feign lookup foo
using stereotype
qualifier. in other words, when consumer application looks eureka, can somehow tell eureka give instance where, example, stereotype
async
? if possible, consumer component can ensure asynchronous workload sent foo
instance deals asynchronous workload.
so far, in research, have not found anything. wrote sample (that can possibly go in discoveryclient
override) use eureka rest interface get /eureka/v2/apps/appid
outlined here , find target endpoint looking metadata map each instance that's returned. sounded brute force. i'd ideally using 1 of existing mechanisms if available, can continue using load balancing , retry features of feign instead of reinventing wheel.
Comments
Post a Comment