1

I am using ZUUL with Eureka.

Lets say, I have two instances of microservice, say test. Their configuration is as follows

spring:
  application:
    name: test
server:
  port: 7878
eureka:
  instance:
    metadata-map:
      version: 1

and

spring:
  application:
    name: test
server:
  port: 7879    
eureka:
  instance:
    metadata-map:
      version: 2

If I send version: 1 in http header then request should go to first instance of microservice and if version: 2 then it should go to second instance microservice.

How can I achieve this ?

Bhushan
  • 1,489
  • 3
  • 27
  • 45
  • I think you would need to add a Filter in your Zuul server that checks the headers. – DaShaun Jan 23 '18 at 15:34
  • I am trying that, but I am not able to figure out how to get service id(ie application name) in ZUUL filter for particular request. – Bhushan Jan 24 '18 at 11:05
  • You have the request object in the filter so you can get the requested URIs and paths which should tell you what application is being requested – DaShaun Jan 24 '18 at 12:37
  • But how to get service ID from request path ? Once I get request ID, I can get all available instances using discovery client. – Bhushan Jan 25 '18 at 07:58
  • The clients are asking ZUUL for some "path" that they want. Zuul is taking that path and routing. I assume that you have zuul.routes.* defined somewhere currently. – DaShaun Jan 25 '18 at 21:15

0 Answers0