These are chat archives for spring-cloud/spring-cloud

22nd
Apr 2018
BenEfrati
@BenEfrati
Apr 22 2018 06:50
Hi,
I think there is two problem with EurekaInstanceConfigBean:
  1. Instantiate too early - for example, if i customize tomcat port WebServerFactoryCustomizer<TomcatServletWebServerFactory>
    @Override
    public void customize(TomcatServletWebServerFactory factory) {
     int serverPort = getPort();
     factory.setPort(serverPort);
    }
    https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java#L141
  2. Why detect securePort from eureka properties instead detecting it at runtime or from ServerProperties
    https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java#L138
Marcos Barbero
@marcosbarbero
Apr 22 2018 07:15
Hello @BenEfrati , for your concerns I've two questions:
For the first topic, why do you need to customize Tomcat's port to be something else than what is set in server.port?
As for the 2nd, picking the property values either from ConfigurableEnvironment or ServerProperties is pretty much the same.
BenEfrati
@BenEfrati
Apr 22 2018 07:17
@marcosbarbero I have port range for the application, and i need to choose port in the range (from properties) so I'm not using server.port at all
  1. boolean isSecurePortEnabled = Boolean.parseBoolean(getProperty("eureka.instance.secure-port-enabled"));
the default is false and you can set the server.ssl.enable to false and eureka.instance.secure-port-enabled to true.
Marcos Barbero
@marcosbarbero
Apr 22 2018 07:24

For me it seems like you have a very specific use case, if you take a look at the first link you sent you'll notice the following signature:

@Bean
@ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT)
public EurekaInstanceConfigBean eurekaInstanceConfigBean(...);

For your case it can be solved if you create a @Bean EurekaInstanceConfigBean and set its values as you need

BenEfrati
@BenEfrati
Apr 22 2018 08:13
I know i can create that bean, just thought one can never know that customize server port pragmatically doesn't affect the eureka config.
What do you think about changing the bean after it's created?
Marcos Barbero
@marcosbarbero
Apr 22 2018 11:05
what do you mean by changing the bean after it's created?
BenEfrati
@BenEfrati
Apr 22 2018 12:03
Autowire in a @Configuration class and then setNonSecurePort()
@Configuration
public class CustomEurekaConfig {
  @Autowire
  private EurekaInstanceConfigBean eurekaInstanceConfigBean;


@PostConstruct
public void init(){
eurekaInstanceConfigBean.setNonSecurePort(getPort());
}
}
Something link that
Jose Armesto
@fiunchinho
Apr 22 2018 12:15
@ryanjbaxter Using apply plugin: 'org.springframework.boot' I get
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/jose.armesto/dev/build.gradle' line: 16

* What went wrong:
A problem occurred evaluating root project 'dev'.
> Could not find method dependencyManagement() for arguments [build_2ddjaw5thgrvojcxiab3wrvd3$_run_closure1@58bc0735] on root project 'dev' of type org.gradle.api.Project.
I'm using the gradle file that is used here http://projects.spring.io/spring-cloud/#quick-start
Marcos Barbero
@marcosbarbero
Apr 22 2018 12:41
@BenEfrati I never tried it and I do believe it won't work
BenEfrati
@BenEfrati
Apr 22 2018 12:45
@marcosbarbero Thanks
Jose Armesto
@fiunchinho
Apr 22 2018 14:50
can anyone else try this gradle file to see if it's broken just for me? http://projects.spring.io/spring-cloud/#quick-start
CH4:D
@chad_d_stud_twitter
Apr 22 2018 15:37
Question regarding the circuit breaker pattern as discussed using Hystrix. Do I no longer need to do any exception catching when i make remote connections like in the example? Does it apply to using feign client connections as well?
@fiunchinho , i'm not getting any errors while I was working with it a while back. what are you getting?
Jose Armesto
@fiunchinho
Apr 22 2018 15:38
I pasted the errors above
CH4:D
@chad_d_stud_twitter
Apr 22 2018 16:30
Okay I think there's a bug in their docs. There's supposed to be org.spribg
Sore
Jose Armesto
@fiunchinho
Apr 22 2018 16:32
so how would the build.gradle be?
CH4:D
@chad_d_stud_twitter
Apr 22 2018 16:32
Sorry. org.springframework prior to the colons
@fiunchinho those should readcompile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-web")
Don't know why the gradle script is broken today.
Jose Armesto
@fiunchinho
Apr 22 2018 16:38
I get the same error
using
buildscript {
        ext {
                springBootVersion = '2.0.0.RELEASE'
        }
        repositories {
                mavenCentral()
        }
        dependencies {
                classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

dependencyManagement {
  imports {
    mavenBom 'org.springframework.boot:spring-cloud-dependencies:Finchley.M9'
  }
}

dependencies {
    compile 'org.springframework.boot:spring-cloud-starter-config'
    compile 'org.springframework.boot:spring-cloud-starter-eureka'
}
repositories {
    maven {
        url 'https://repo.spring.io/libs-milestone'
    }
}
Andrew Fitzgerald
@fitzoh
Apr 22 2018 18:47
@spencergibb I’ve been operating under the assumption that using a hystrix filter is currently the “correct” way to set different timeouts for different routes for spring-cloud-gateway, is that correct?