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

6th
Aug 2018
Krzysztof Koziol
@koziolk
Aug 06 2018 11:34
Hi There
Marcos Barbero
@marcosbarbero
Aug 06 2018 11:35
Hi there
Krzysztof Koziol
@koziolk
Aug 06 2018 11:36
After upgrade to Finchley.SR1 and Spring Boot 2.0.4 I'm getting the following exception
feign.RetryableException: Read timed out executing GET xxxxxx
at feign.FeignException.errorExecuting(FeignException.java:67) ~[feign-core-9.5.1.jar!/:na]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:104) ~[feign-core-9.5.1.jar!/:na]
Krzysztof Koziol
@koziolk
Aug 06 2018 11:59
Has anything changed in Feign/Eureka configuration since Finchley.RELEASE?
Spencer Gibb
@spencergibb
Aug 06 2018 15:28
@koziolk not that I'm aware of
Joshua Street
@jjstreet
Aug 06 2018 19:27
hey all
im looking at cloud-gateway as a replacement for some Zuul stuff we have in play
im trying to draw comparisons between the different parts of each library
right now in Zuul i have a filter that reads from a request body and stores a bit of data in the request context object that is given to all filters in the chain
Spencer Gibb
@spencergibb
Aug 06 2018 19:29
such as?
Joshua Street
@jjstreet
Aug 06 2018 19:29
im trying to understand how i might do that in cloud gateway
im working on a filter cloud gateway that would read teh request body and store the value i need in the exchange object
i dont need to modify it, just read it
Joshua Street
@jjstreet
Aug 06 2018 19:32
Zuul has a bit of flexibility in that one filter could add to the request context and a filter that operates later could use that data
Spencer Gibb
@spencergibb
Aug 06 2018 19:32
There is a modifyResponseBody() filter (no need to actually modify it), but it takes care of caching it (since in webflux, you can only have one subscriber to the request data).
Joshua Street
@jjstreet
Aug 06 2018 19:32
ahh
Spencer Gibb
@spencergibb
Aug 06 2018 19:33
just put it in the ServerWebExchange request attributes, no need for a separate data structure
Joshua Street
@jjstreet
Aug 06 2018 19:33
ok
Spencer Gibb
@spencergibb
Aug 06 2018 19:33
gateway does it many places
Joshua Street
@jjstreet
Aug 06 2018 19:33
oh really?
ive seen instances of a filter writing to exchange and then removing it
but never writing and then another filter useing it
Spencer Gibb
@spencergibb
Aug 06 2018 19:34
It does
Joshua Street
@jjstreet
Aug 06 2018 19:35
so its safe to say that filters in gateway act very similar in spirit to filters in Zuul
Spencer Gibb
@spencergibb
Aug 06 2018 19:35
it's how the response is written back to the client in a different filter.
Joshua Street
@jjstreet
Aug 06 2018 19:35
with the exchange object being close what request context does
true true
so i will just add my own filters to write and read from exchange
Spencer Gibb
@spencergibb
Aug 06 2018 19:39
:+1: the attributes are request scoped
Joshua Street
@jjstreet
Aug 06 2018 19:39
perfect
Spencer Gibb
@spencergibb
Aug 06 2018 19:40
I put the reactor netty response object in the request attributes
Joshua Street
@jjstreet
Aug 06 2018 19:40
im using the ModifyRequestBodyGatewayFilterFactory as a model for my own filter that reads from the request body
i guess the BETA warnings in the javadocs gave me pause
Spencer Gibb
@spencergibb
Aug 06 2018 19:42
just means the interface could change, the programming model is fine
Joshua Street
@jjstreet
Aug 06 2018 19:42
im also new to Reactor and webflux so when i see how much there is to read the body, it raised an eyebrow
Spencer Gibb
@spencergibb
Aug 06 2018 19:43
in a normal webflux app, spring handles all that for you, the gateway is a bit outside that
Joshua Street
@jjstreet
Aug 06 2018 19:43
ahh
wonder if there is an opportunity here to abstract some of this in way that is easier to work with?
not just when defining routes
but also when defining filters that need to read data from a request
to something else (i need a field value to help determine where to send the request to)
Spencer Gibb
@spencergibb
Aug 06 2018 19:44
only when reading from the request body
Joshua Street
@jjstreet
Aug 06 2018 19:45
yea
Spencer Gibb
@spencergibb
Aug 06 2018 19:45
I try to not encourage that since that implies memory constraints since you have to read to memory
Joshua Street
@jjstreet
Aug 06 2018 19:46
but haven't you done that with the current request body filter already?
Spencer Gibb
@spencergibb
Aug 06 2018 19:47
yes
I still just want the warning out there.
if your client can give you the piece of data outside the body (header, parameter, path, host, etc...) it would eliminate the memory constraints
Joshua Street
@jjstreet
Aug 06 2018 19:49
true
our API leaves my head spinning
i just realized: I can use a rewrite function to store the data in the exchange object, without actually having to use my own filter
Spencer Gibb
@spencergibb
Aug 06 2018 19:51

hence my statement

modifyResponseBody() filter (no need to actually modify it)

Joshua Street
@jjstreet
Aug 06 2018 19:52
i misread your statement
i didnt put that statement together with your link to some code until now
Spencer Gibb
@spencergibb
Aug 06 2018 19:52
:-)
Joshua Street
@jjstreet
Aug 06 2018 19:58
return builder.routes()
                .route(r -> r.path("/greet")
                        .filters(f -> f.modifyRequestBody(JsonNode.class, JsonNode.class,
                                (exchange, node) -> {
                                    String recipient = node.at("recipient").asText();
                                    if (!recipient.isEmpty()) {
                                        exchange.getAttributes().put(RouterWebExchangeConstants.RECIPIENT_KEY, recipient);
                                    }
                                    return Mono.just(node);
                                }))
                        .uri("SOME URI"))
                        .build();
something like that would work just fine
i need to perform a look up of data i receive in the body, and choose a URI based on that
this gets me that data in exchange
but i still have to specify a URI
Spencer Gibb
@spencergibb
Aug 06 2018 20:02
yes, I did something like no://op the other day
Joshua Street
@jjstreet
Aug 06 2018 20:02
lol nice
but wont the URI i specify there be set after my filters have processed?
Spencer Gibb
@spencergibb
Aug 06 2018 20:03
it happens early
Joshua Street
@jjstreet
Aug 06 2018 20:03
ok so i have ability to modify the URI as part of the filter processing
the URI is set in the exchange ahead of time
Spencer Gibb
@spencergibb
Aug 06 2018 20:03
yes, it happens when the predicates match the request
Joshua Street
@jjstreet
Aug 06 2018 20:04
understood
Joshua Street
@jjstreet
Aug 06 2018 20:12
AbstractChangeRequestUriGatewayFilterFactory.class i can use this as a base for my own URI filter
Joshua Street
@jjstreet
Aug 06 2018 20:54
shit i dont even need my own class here either