Closed sowston closed 8 years ago
This is a setting for eureka NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
.
Do you have a service with spring.application.name=RandomNumber
?
I am unable to reproduce. Do you have a project to share?
Yes, I have an entire workspace I can share. What is the best way to share it?
Yes, I have a service "RandomNumber" Service, it's a REST service with one "randomnumber" resource that supports GET. I will send it forward with the workspace to u. Can also provide a vagrant workspace to spin up the env.
@sowston however you want to get it to me. Dropbox, google drive, email, whatever.
Here's the Google Drive link to the RandomNumber REST Web Service Project: https://drive.google.com/file/d/0B5e-22Pji8-_bDRLR0xwMUlKMnc/view?usp=sharing
Here's the link to my SpringCloud Client Project: https://drive.google.com/file/d/0B5e-22Pji8-_czV5T0RXN2gwclk/view?usp=sharing
Here's the vagrant env files: https://drive.google.com/file/d/0B5e-22Pji8-_Z2w1Zkc4cG8wNVU/view?usp=sharing
and thanks!
@spencergibb if there is a chance for you to look at this issue, I would be most appreciative. I can't seem to get around the issue.
also, here's the service.json to configure consul with the RandomNumber service:
randomnumberservice.json node 3:
{
"service": {
"name": "RandomNumber",
"tags": ["stateless"],
"address": "172.20.20.30",
"port": 8080
,
"checks": [
{
"id": "RandomNumberRESTGetCheck",
"http": "http://localhost:8080/services/rest/health",
"interval": "3s",
"timeout": "1s"
}
]
}
}
node 4 and 5 have the same config, with address: .40 and .50 respectively.
hmm, I've never used json to configure consul, I let spring-cloud do it.
you just drop that json file in the consul config directory. then do consul reload to load the config and the service will be registered in the catalog.
I know what it's for, just wondering if that's part of the problem. Hoping to look at this soon.
sure, ok, np. thank u sir!
I've had a bit of a look. I didn't use any of your infrastructure setup (too much for me to try and isolate), just the source of your two projects. I ran two instances of RandomNumber
and found a problem with the json you gave me. I had to set a unique id for each one, otherwise they stomped on each other. That might be what you are experiencing, only one actually registered with consul. I deployed 2 RandomNumber
services, therefore I saw "4 passing" in the consul ui under services. The other issue was you pom.xml mixing releases. I've put an updated one below. Can you try with those changes and see if you are still seeing problems. I also commented out all entries under RandomNumberClient
in application.yml` (none of it is needed by default).
randomnumberservice1.json
{
"service": {
"id": "RandomNumber1",
"name": "RandomNumber",
"tags": ["stateless"],
"address": "localhost",
"port": 8081,
"checks": [
{
"id": "RandomNumberRESTGetCheck",
"http": "http://localhost:8081/services/rest/health",
"interval": "3s",
"timeout": "1s"
}
]
}
}
randomnumberservice0.json
{
"service": {
"id": "RandomNumber0",
"name": "RandomNumber",
"tags": ["stateless"],
"address": "127.0.0.1",
"port": 8080,
"checks": [
{
"id": "RandomNumberRESTGetCheck",
"http": "http://127.0.0.1:8080/services/rest/health",
"interval": "3s",
"timeout": "1s"
}
]
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.viasat.services.rest.randomnumber</groupId>
<artifactId>RandomNumberSpringCloudClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RandomNumberSpringCloudClient</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RC1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.M2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<!--skip deploy -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<!-- Only needed at compile time -->
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Simplified RandomNumberClient.java
package com.viasat.services.rest.randomnumber;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@RestController
@EnableFeignClients
@Slf4j
public class RandomNumberClient {
@Autowired
private RandomNumberFeignClient client;
@RequestMapping("/")
public String getRandomNumber() {
return client.getRandomNumber();
}
public static void main(String[] args) {
SpringApplication.run(RandomNumberClient.class, args);
}
@FeignClient("RandomNumber")
public interface RandomNumberFeignClient {
@RequestMapping(value = "/services/rest/randomnumber", method = RequestMethod.GET)
String getRandomNumber();
}
}
Thanks @spencergibb
I'm getting the following error when trying to build with the POM you provided:
Plugin org.springframework.boot:spring-boot-maven-plugin:1.3.0.RC1 or one of its dependencies could not be resolved: Failure to find org.springframework.boot:spring-boot-maven-plugin:jar:1.3.0.RC1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Don't know how that's possible with
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
http://repo.spring.io/milestone/org/springframework/boot/spring-boot-maven-plugin/1.3.0.RC1/
M2 Eclipse Plugin hell. Great, I no longer see the bahavior after making the ID's unique, simplifying the client and updating the POM. This issue can be closed. Thanks for your help @spencergibb
Totally understand that it's in milestone, but it would be great if the POM's for the examples were up to date and possibly a couple more examples would be extremely helpful.
Nice work sir.
NP, we appreciate the feedback!
I am witnessing inconsistent failover behavior of the loadbalancer in destructive testing of a REST service that I'm hitting from my FeignClient.
I have a 5 node Consul cluster running in vagrant:
I have deployed a random number web service and registered the service on N3, N4, N5.
I have a SpringBoot application with a FeignClient with autowired LoadBalancer and Consul DiscoveryClient.
The load balancer is working properly when all three services are "UP". If I hard kill a web service node, for example (service randomnumber stop) on the N3 node, I see the the FeignClient properly failover only a couple requests, then eventually it begins to throw this exception:
RandomNumberClient.java
bootstrap.yml
application.yml