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

5th
Mar 2019
Spencer Gibb
@spencergibb
Mar 05 00:49 UTC
what if there is no filter that modifies the url?
Ashok Koyi
@thekalinga
Mar 05 09:58 UTC
Whoever needs the URI will get it from using exchange.getRequest().getURI()
Patrick Gotthard
@PatrickGotthard
Mar 05 13:53 UTC
@marcosbarbero @tkvangorder Sorry for the late response. Of course it would be great to just shut down out services and wait for current requests to be processed. BUT neither Zuul (in default configuration) nor Spring Cloud Gateway support retry for PUT, POST and DELETE request. And currently our clients are not smart enough to retry such requests themself.
*our
Patrick Gotthard
@PatrickGotthard
Mar 05 13:59 UTC
@tkvangorder Of course we now deregister from eureka, wait for 30 seconds and then shutdown tomcat gracefully
gitmnd
@gitmnd
Mar 05 14:05 UTC
How can i use spring-cloud gateway functionality to direct to multiple services based on a parameter from body .Ex: if i have action param in request body and every request contain different values like ACCEPT,CREATE,REMOVE .
each of the action has separate endpoint available to fullfil the request
Spencer Gibb
@spencergibb
Mar 05 14:43 UTC
@thekalinga that's the uri from the request, not where it is being routed
@PatrickGotthard retry with a body is problematic for various reasons
Spencer Gibb
@spencergibb
Mar 05 14:53 UTC
@gitmnd there is a readBody() predicate in the javadsl
gitmnd
@gitmnd
Mar 05 14:54 UTC
Thanks. I have below example code to try this first time
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route( r -> r.path("/accept")
.uri("http://localhost:9090/doAccept"))
            .route( r -> r.path("/decline")
                    .uri("http://localhost:9090/doDecline"))
            .build();

}

@RequestMapping(value="/doAccept")
public void doAccept(){
    LOGGER.info("doAccept controller is called");
}
sorry for bad formatting here
when i hit "http://localhost:9090/accept " = > "doAccept controller is called" is never printed
there are no failure logs ..what am i missing?
Spencer Gibb
@spencergibb
Mar 05 15:05 UTC
the path on the uri is not used. You need to use a filter setPath("/doAccept")
gitmnd
@gitmnd
Mar 05 15:18 UTC
i am trying with setting like this " .filter( f-> f.setPath("/") )"
is this correct? it does not compile though
Spencer Gibb
@spencergibb
Mar 05 15:19 UTC
why "/"?
Ashok Koyi
@thekalinga
Mar 05 15:19 UTC
@spencergibb Thanks for that calrification. I need to do some digging
Spencer Gibb
@spencergibb
Mar 05 15:19 UTC
I can't tell you why it won't compile.
gitmnd
@gitmnd
Mar 05 15:19 UTC
@spencergibb setPath is complaining not to compile
gitmnd
@gitmnd
Mar 05 15:25 UTC
It worked now
.route(r -> r.path("/accept")
.filters(f -> f.setPath("http://localhost:9090/doAccept"))
.uri("http://localhost:9090/doAccept")
)
I was using filter rather filters
Spencer Gibb
@spencergibb
Mar 05 15:25 UTC
.route(r -> r.path("/accept")
.filters(f -> f.setPath("/doAccept"))
.uri("http://localhost:9090")
)
is more correct
gitmnd
@gitmnd
Mar 05 15:27 UTC
sure .. thanks
Patrick Gotthard
@PatrickGotthard
Mar 05 17:42 UTC
@spencergibb We want to add a simple "alias" for a service that will be configured automatically in Spring Cloud Gateway. E.g. when the service is available as <gateway>/newservicename we want the clients to be able to call <gateway>/oldservicename too. How to configure that?
Patrick Gotthard
@PatrickGotthard
Mar 05 17:48 UTC
And services that will be configured by the DiscoveryLocator must be called with a trailing /. Is it possible to remove this / at the end?
Spencer Gibb
@spencergibb
Mar 05 20:08 UTC
@PatrickGotthard what have you tried?
gregstont
@gregstont
Mar 05 21:29 UTC
hello... I'm currently getting "connection reset" exceptions while using spring-retry with my Zuul proxy. It works fine with Edgware.SR1, but not any of the subsequent Edgware SRs. Any idea what the issue could be?
gregstont
@gregstont
Mar 05 21:35 UTC
@PatrickGotthard I am not familiar with Gateway, but we needed something similar for our Eureka/Zuul setup... ended up extending DiscoveryClientRouteLocator to pull route definitions from the eureka InstanceInfo metadata-map
Tyler Van Gorder
@tkvangorder
Mar 05 22:03 UTC

@PatrickGotthard

We do have this working in our environment (~500 million requests a week going through spring cloud sidecar) We are able to do automated rolling deployments without producing client-side errors by doing the following (and it was not easy to get here):

We do retry all requests which, at first, is not intuitive but we rationalize that the user, upon getting an error, is likely to just try the request again. As Spencer noted, doing a retry on a post/put/delete (with a request body) can be troubling in timeout situations but in the three plus years of production use, we have only run into one specific situation where this came to bite us.

To maybe help you, our configuration looks like this:

# Configuring the number of connection failures before tripping the circuitBreaker
niws:
  loadbalancer:
    connectionFailureCountThreshold: 2

ribbon:
  ConnectTimeout: 1000
  ReadTimeout: 20000
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 2
  OkToRetryOnAllOperations: true
  MaxHttpConnectionsPerHost: 200
  MaxTotalHttpConnections: 1000
zuul:
  retryable: true

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 61000

We also have a custom retry handler that adds "UnknownHostException":

public class CustomRetryHandler extends HttpClientLoadBalancerErrorHandler {

    public CustomRetryHandler(IClientConfig clientConfig) {
        super(clientConfig);
        circuitRelated.add(UnknownHostException.class);
        retriable.add(UnknownHostException.class);
    }

    public CustomRetryHandler(int retrySameServer,
            int retryNextServer, boolean retryEnabled) {
        super(retrySameServer, retryNextServer, retryEnabled);
        circuitRelated.add(UnknownHostException.class);
        retriable.add(UnknownHostException.class);
    }

    public CustomRetryHandler() {
        super();
        circuitRelated.add(UnknownHostException.class);
        retriable.add(UnknownHostException.class);
    }
}