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

27th
Feb 2019
Patrick Gotthard
@PatrickGotthard
Feb 27 07:38

@marcosbarbero Thanks for your valuable tipps. I finally managed to get our zero-downtime deployment working with the following settings:

# eureka server
eureka.server.response-cache-update-interval-ms: 1000

# gateway
eureka.client.registry-fetch-interval-seconds: 5
ribbon.ServerListRefreshInterval: 5000

Our services will unregister from eureka and wait 15 secods before shutting down:

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

import com.netflix.discovery.EurekaClient;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Configuration
@ConditionalOnProperty(name = { "eureka.client.enabled", "eureka.client.register-with-eureka" }, matchIfMissing = true)
@Order(Ordered.HIGHEST_PRECEDENCE)
@AllArgsConstructor
@Slf4j
class EurekaShutdownConfiguration implements ApplicationListener<ContextClosedEvent> {

    private final EurekaClient client;

    @Override
    public void onApplicationEvent(final ContextClosedEvent event) {
        try {
            log.info("Gracefully shutting down");
            this.client.shutdown();
            Thread.sleep(15_000);
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }

}

Additionally I'll configure some retry logic on the spring-cloud-gateway for some unexpected other reasons (e.g. server failure and network errors) to be even more failure tolerant

Marcos Barbero
@marcosbarbero
Feb 27 07:40
I'm glad you managed to make it work!
Archimedes Trajano
@trajano
Feb 27 19:31
Is there a spring-cloud-streams channel?
I just did this
image.png
Marcos Barbero
@marcosbarbero
Feb 27 19:32
Spring cloud stream without the extra s
Archimedes Trajano
@trajano
Feb 27 19:33
thanks
there you go
Archimedes Trajano
@trajano
Feb 27 19:50
yup thanks I asked my question there already.