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

Sep 2018
Tommy Ludwig
Sep 19 2018 07:44
Is the abscence of a Finchley.SR2 on the milestones page an indication there is no currently planned release date for SR2?
Marcin Grzejszczak
Sep 19 2018 13:30
there will be one
Andrew Fitzgerald
Sep 19 2018 13:36
@spencergibb I’m under the impression that there’s nothing in SCG to allow sticky routing, is that correct?
Spencer Gibb
Sep 19 2018 15:29
@Fitzoh no
Andrew Fitzgerald
Sep 19 2018 15:31
might write something up on the approach we’re using if there’s potentially interest
Spencer Gibb
Sep 19 2018 15:31
Andrew Fitzgerald
Sep 19 2018 15:32
short version:
 * Uses cookies to ensure that the same server is routed to for all subsequent requests.
 * On the initial request when no cookie is set, a random server id is chosen and sent back to the client.
 * On subsequent requests, the cookie is validated to make sure the server is still active.
 * If the cookie is invalid, a new one is generated.
 * <p>
 * Also sets the {@link StickyRoutingFilter#GATEWAY_ROUTING_ATTRIBUTE } for use in {@link CfUrlDeterminer}.
public class StickyRoutingFilter implements GatewayFilter {
    public static final String GATEWAY_ROUTING_ATTRIBUTE = "connect-gateway-routing";
    public static final String GATEWAY_ROUTING_COOKIE = "connect-gateway-routing";
    private final ServerList serverList;

    public StickyRoutingFilter(ServerList serverList) {
        this.serverList = serverList;

    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        System.out.println("in filter");

        return chain.filter(exchange);

    public void modifyExchange(ServerWebExchange exchange) {
        String serverIdentifier = getExistingCookieValue(exchange)
                .orElseGet(() -> {
                    String server = serverList.getRandomServerIdentifier();
                    exchange.getResponse().addCookie(ResponseCookie.from(GATEWAY_ROUTING_COOKIE, server).build());
                    return server;
        exchange.getAttributes().put(GATEWAY_ROUTING_ATTRIBUTE, serverIdentifier);


    private Optional<String> getExistingCookieValue(ServerWebExchange exchange) {
        List<HttpCookie> cookies = exchange.getRequest().getCookies().get(GATEWAY_ROUTING_COOKIE);
        if (cookies == null || cookies.isEmpty()) {
            return Optional.empty();
        return Optional.of(cookies.get(0).getValue());
Eric Deandrea
Sep 19 2018 20:52
Can a Spring boot EnvironmentPostProcessor read values that are provided from a config server by spring-cloud-config-client? When debugging I don’t see the configService property source in the ConfigurableEnvironment.getPropertySources()