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

23rd
Sep 2016
David Welch
@dwelch2344
Sep 23 2016 03:33
Hmm, anyone here gotten feign to play nice with hal+json? We seem to have issues deserializing lists
Looks like the SpringDecoder doesn't get wired up with the HAL message converters if they're around
@dsyer @spencergibb: looking through how the decoders and message converters are created and seeing lots of refs to you two. Is there a preferred way of customizing / augmenting the FeignClientsConfiguration#messageConverters?
David Welch
@dwelch2344
Sep 23 2016 04:37
Looks like returning Resources on the Feign side of things will do the trick. Feels dirty tho
Oliver Drotbohm
@odrotbohm
Sep 23 2016 06:31
@ccit-spenceDiscoveredResource basically adds resource discovery (hence the name) on top of service discovery. You describe a DR by taking a service instances and a traversal description to find the resource you're interested in. That description is using Spring HATEOAS' Traverson which means that unqualified link relations are evaluated depending on what hypermedia type the server returns. However, if you let them start with $, they basically become JSON Path expressions, so that you can point at some element in the JSON directly.
ccit-spence
@ccit-spence
Sep 23 2016 06:31
@olivergierke Yep, I have it working now. Never knew it was there
Oliver Drotbohm
@odrotbohm
Sep 23 2016 06:32
:)
ccit-spence
@ccit-spence
Sep 23 2016 06:33
how do you handle different root paths?
i.e. localhost/path1 localhost/path2
it seems to only want to start at a base and then follow rels
ccit-spence
@ccit-spence
Sep 23 2016 06:45
@olivergierke I did wonder how a fallback works with this?
Stian Lågstad
@stianlagstad
Sep 23 2016 08:10
Hi. I'm trying to use Wiremock to test that my code handles a Feign client's timeout-exception (HystrixRuntimeException with failuretype "TIMEOUT") like I want it to. I'm using Wiremock to stub my Feign client call with a fixed delay at 11000, and I've set the hystrix.command.myFeignMethod.execution.isolation.thread.timeoutInMilliseconds: 10000. Still, I'm not getting a hystrix exception after 10000ms as I expect. Is there something special I have to do in order to make this work? Alternatively: Is there a suggested way to test that my code handles timeout errors from Feign clients as I expect? I'm using spring boot 1.4.1 and spring-cloud-dependencies:Camden.RC1.
Dave Syer
@dsyer
Sep 23 2016 08:11
How did you set up the stub?
Maybe a sample project would make things clearer?
Stian Lågstad
@stianlagstad
Sep 23 2016 08:12
        stubFor(get(urlPathMatching("/\\w{3}/productGroups/\\d+/products"))
                .willReturn(aResponse()
                        .withStatus(200)
                        .withFixedDelay(11000)
                        .withHeader("Content-Type", "application/json")
                        .withBodyFile("fara/fara-product.json")));
When I call it, it waits 11 seconds and returns. I want hystrix to break it after 10. Should it break after 10 if I've set the timeoutInMilliseconds correctly?
Oliver Drotbohm
@odrotbohm
Sep 23 2016 08:13
@ccit-spence — You don't. You start at the service root URI, whatever the service discovery returns in the first place. The whole exercise's goal is to not have clients that know about URI patterns, as they might change, which is one of the issues I have with Feign for example.
Dave Syer
@dsyer
Sep 23 2016 08:16
@stianlagstad there are multiple different timeout settings that might be relevant
The hystrix one probably is relevant
Did you spell the command name correctly?
(I'm not sure what Feign does with Hystrix - how it creates the command name)
ccit-spence
@ccit-spence
Sep 23 2016 08:17
@olivergierke Ok, that is what I thought. Just wanted to be sure. So hit a base app and traverse with rels
And exactly about Feign, it is configured to a set endpoint
Dave Syer
@dsyer
Sep 23 2016 08:18
You could set the default timeout and see if that works.
Stian Lågstad
@stianlagstad
Sep 23 2016 08:36
Setting the default worked: hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1. I thought I could replace "default" there with my Feign method name, e.g. hystrix.command.getFaraStops.execution.isolation.thread.timeoutInMilliseconds: 1, but it's not working. Gonna try some more
Stian Lågstad
@stianlagstad
Sep 23 2016 08:51
How do I set the timeout limit on a specific feign method?
ccit-spence
@ccit-spence
Sep 23 2016 08:54
@olivergierke If I do the follwing and that service is down, it stops any results from showing. Is there a more graceful way to handle a down endpoint?
    @Bean
    public DynamicServiceInstanceProvider dynamicServiceProvider(DiscoveryClient client) {
        return new DynamicServiceInstanceProvider(client, "vr-dms-cmd-attractions");
    }
Dave Syer
@dsyer
Sep 23 2016 09:02
@stianlagstad you need to know the command name
I'm not sure that the method name is the command name for Feign clients
I'm sure it's easy to find out though
E.g. look at the /hystrix.stream and look at the command names
Or read the source code (maybe even the docs if you're lucky)
It's in openfeign I think, and there's a gitter room for that as well
Stian Lågstad
@stianlagstad
Sep 23 2016 09:04
Thanks, I'll look more into it. It's weird, because I'm fairly certain I could set the timeout for specific feign methods with that approach before
Dave Syer
@dsyer
Sep 23 2016 09:04
Don't know. It would work with @HystrixCommand I think.
Oliver Drotbohm
@odrotbohm
Sep 23 2016 09:58
@ccit-spence — But isn't that exactly what graceful degradation is about? The discovered resource becomes unavailable and you can act on that fact: https://github.com/olivergierke/rest-microservices/blob/master/customer-service/src/main/java/example/customers/integration/CustomerResourceProcessor.java#L53-L66
ankit8051
@ankit8051
Sep 23 2016 10:36

Hi Team, I have one question regarding the Cloud Config encryption and Cloud Config client decryption.

I have created one config server and added below configuration in application.yml file.

encrypt:
  keyStore:
    location: classpath:/server.jks
    password: letmein
    alias: mytestkey
    secret: changeme

I have followed the same steps provided by spring cloud config document.

This configuration exposed two end point /encrypt and /decrypt. A am able to encrypt and decrypt the values using these end point.

I have encrypted one of my password using /encrypt end point then stored this value in my repository.

password:'{cipher}{key:myTestKey}AXRTSADsadasdasd123asd='

But when I am tried to fetch the value from my config client it is not automatically decrypted. I am getting the '{cipher}{key:myTestKey}AXRTSADsadasdasd123asd=' the same value as I have configured in my repository.

My config client application's bootstrap.yml has below configuration.

encrypt:
  keyStore:
    location: classpath:/server.jks
    password: letmein
    alias: mytestkey
    secret: changeme
Dave Syer
@dsyer
Sep 23 2016 10:37
Please use markdown formatting for code and logs
Fences (``` on a line) around code content will be a good start
ankit8051
@ankit8051
Sep 23 2016 10:38
Corrected
Dave Syer
@dsyer
Sep 23 2016 10:39
Thanks. Much better.
Don't you have to enable encryption on the server side?
The client doesn't need the keystore
if you want the decryption to happen server side
(maybe that's wrong?)
This message was deleted
ccit-spence
@ccit-spence
Sep 23 2016 10:42
@olivergierke Yes it is, should have clarified. This is a client service composing different endpoints. all results die even the working services
Dave Syer
@dsyer
Sep 23 2016 10:42
I think also in YAML you might need to escape the first { (as \{)
ankit8051
@ankit8051
Sep 23 2016 10:47

@dsyer ,
I have one confusion.

I am under impression that On server we have to store the sensitive information in encryption form. Using {cipher}{key:testKey} format. And client will automatically decrypt it by using testKey.

am I on right track?

ccit-spence
@ccit-spence
Sep 23 2016 10:51
@olivergierke Nevermind I had an issue. Will test more on my end. Thanks for sharing the excerpt. makes perfect sense
ankit8051
@ankit8051
Sep 23 2016 11:57
@dsyer, I need the decryption on client side.
Dave Syer
@dsyer
Sep 23 2016 12:56
There's no support for {key:testKey} (or other attributes) on the client side IIRC
And I believe you need to explicitly switch off decryption on the server if you want to do it client side
pradeepkusingh
@pradeepkusingh
Sep 23 2016 14:34
This message was deleted
This message was deleted
This message was deleted
This message was deleted
Dave Syer
@dsyer
Sep 23 2016 14:36
It's a Spring Boot / Spring Data question
pradeepkusingh
@pradeepkusingh
Sep 23 2016 14:38
ok. Thanks, Moved.
Dennis Melzer
@SirWayne
Sep 23 2016 15:51
Hello, is it possible to create a session scoped @EventListener? I need a event listener for every UI. Found here a old thread http://forum.spring.io/forum/spring-projects/container/28435-applicationlistener-in-session-scope-bean-fails
Dave Syer
@dsyer
Sep 23 2016 15:56
If the events you are sending are generated in a web request I guess that would work
I never tried it.
You'd need a lazy init scoped proxy for the listener make sure it wasn't instantiated on startup.
Events are processed in the thread that publishes them by default. So if you haven't changed the multicaster, my guess is it would work.
On the other hand I'm not sure it wouldn't be easier to solve the other way round: make the publisher session scoped and create an event with the data you need in the listener there.
(Nothing to do with Spring Cloud, right?)
Dennis Melzer
@SirWayne
Sep 23 2016 16:00
ah sorry you are right wrong chat
Dennis Melzer
@SirWayne
Sep 23 2016 16:21
but btw. it works :). You have to add the application listener to the context.
@dsyer :+1:
bitsofinfo
@bitsofinfo
Sep 23 2016 17:34
@spencergibb so this issue I was describing yesterday, its pretty hard to reproduce but only happens when you have 2 services that come up at approximately the same time, where one depends on the other, whatever "state" it gets on that initial query w/ eureka is never updated by deltas after that.
The dependent service needs to be restarted to fix it. After that any changes that occur seem fine. I cannot find any way to FORCE a full refresh of the registry from Eureka w/ that DiscoveryClient
Is there a way? that refresh method is private and only invoked by its own thread.
and its delta only
It appears the full refresh is only done if there is some sort of region change
Spencer Gibb
@spencergibb
Sep 23 2016 17:44
@bitsofinfo I’ve never seen that before. I’d need a project that reproduces the problem to look at it more
bitsofinfo
@bitsofinfo
Sep 23 2016 17:46
understood, regarding DiscoveryClient, do you know of any way of I could do a full refresh from eureka other than the switches here that trip it? https://github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/discovery/DiscoveryClient.java#L932
Spencer Gibb
@spencergibb
Sep 23 2016 17:46
no
bitsofinfo
@bitsofinfo
Sep 23 2016 18:05
Is DiscoveryClient shared by all Feign/Ribbon clients or is there a separate instance per client?
Spencer Gibb
@spencergibb
Sep 23 2016 18:09
shared
bitsofinfo
@bitsofinfo
Sep 23 2016 18:10
if I extended DiscoveryClient and created a @Bean @Primary would it replace that one
Spencer Gibb
@spencergibb
Sep 23 2016 18:22
If it were named right I think DiscoveryClient discoveryClient
bitsofinfo
@bitsofinfo
Sep 23 2016 18:27
or I'd extend CloudEurekaClient