0

I use Spring Cloud in my microservice project with Eureka and Zuul. I want to communicate between my microservices using a Feign client. Say i have a microservice Microservice1 and Microservice2. In addition, i have the Eureka microservice and the Zuul microservice.

Zuul is configured as follows:

zuul:
ignoredServices: "*"
sensitiveHeaders: Authorization
routes:
    empty_calls:
        path: /
        serviceId: microservice1
    microservice1:
        path: /microservice1/**
        serviceId: microservice1
    microservice2:
        path: /microservice2/**
        serviceId: microservice2
host:
    connect-timeout-millis: 10000
    socket-timeout-millis: 60000

In my Microservice2, I have the following Feign client:

@FeignClient(name = "microservice1")
public interface Microservice1Client {

    @RequestMapping(value = "/test/this_is_a_test",
            method = RequestMethod.POST,
            consumes = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResponseEntity<Boolean> addTestObject(@RequestBody List<String> userMails);

}

My problem is the following: I want the feign client to call my REST service via e.g. localhost:8080/microservice1/test/this_is_a_test. Instead, it calls "http://microservice1/test/this_is_a_test". I don't want to configure the feign client manually using the url attribute - it works automatically in other applications, but not for this specific configuration. Can anybody help me here?

Edit

The Eureka dashboard:

enter image description here

Leonard
  • 783
  • 3
  • 22
  • I am not sure whether I am following your question. Your Feign client is pointing to REST service with ID `microservice1`. Any invocation of method `addTestObject` in `Microservice1Client` will map to `http://:/microservice1/test/this_is_a_test`. Where is `microservice` coming from? – Indra Basak Oct 13 '17 at 18:41
  • Thanks for your answer. "Any invocation of method addTestObject in Microservice1Client will map to http://:/microservice1/test/this_is_a_test" - Yep, this is what i want. But this is not what it does, it calls "http://microservice1/test/this_is_a_test" - I have no idea why. All microservices are running on the same host. – Leonard Oct 27 '17 at 09:22
  • Is your Eureka set up correctly? Please post a screenshot of your Eureka dashboard? – Indra Basak Oct 27 '17 at 23:33
  • I added the Eureka dashboard (the question is still relevant to me :-S ) – Leonard Apr 30 '18 at 08:34

0 Answers0