Reputation: 121
My application connects with multiple REST APIs.
I've been successful in adding a Ribbon Client/Load Balance to my application for one of those APIs with its own list of servers
Now I'd like to add a second client that would hold the server list for my second API.
In order to define my client name which is used by Archaius to load specific properties, I added the following property.
ribbon.client.name=myFirstClientName
My question is: How do I define another client on the same application?
I thought it would be a comma-separated list like:
ribbon.client.name=myFirstClientName,mySecondClientName
However, this didn't work.
Eventually, I want to end up with two lists of servers like
myFirstClientName.ribbon.listOfServers=<ip>,<ip>
mySecondClientName.ribbon.listOfServers=<ip>,<ip>
Any thoughts?
Upvotes: 4
Views: 1938
Reputation: 121
I was able to make it work by adding a @RibbonClient
annotation on the interfaces I created for Feign.
The resulting class would be
@FeignClient("http://myFirstClientName/")
@RibbonClient(value = "myFirstClientName", configuration = MyFirstClientConfig.class)
public interface MyFirstFeignService {
Second Client would be:
@FeignClient("http://mySecondClientName/")
@RibbonClient(value = "mySecondClientName", configuration = MySecondClientConfig.class)
public interface MySecondFeignService {
Then of course I would set my two lists of server ips
myFirstClientName.ribbon.listOfServers=<ip>,<ip>
mySecondClientName.ribbon.listOfServers=<ip>,<ip>
PS: Make sure your config classes - MySecondClientConfig and MyFirstClientConfig - above are NOT on the ApplicationContext. Don't let it be caught by some @ComponentScan somewhere or else it won't work.
Upvotes: 3