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

11th
Jun 2018
CH4:D
@chad_d_stud_twitter
Jun 11 2018 05:21
Consul has no support for db-based configs unlike Eureka. Do I understand this correctly?
Marcos Barbero
@marcosbarbero
Jun 11 2018 05:48
The other way around.
CH4:D
@chad_d_stud_twitter
Jun 11 2018 06:13
umm
i can confirm eureka has db and git support
it’s actually well documented for that
Marcos Barbero
@marcosbarbero
Jun 11 2018 06:14
What do you mean by DB support?
CH4:D
@chad_d_stud_twitter
Jun 11 2018 06:14
but couldn’t find something similar in consul
if you wanted the config keys to be hosted in a db rather than git, you can do it in eureka
we don’t need it now but just want to be ready in case our stakeholders ask
Marcos Barbero
@marcosbarbero
Jun 11 2018 06:17
Can you share it, please? I doubt if I saw this db based config documentation before
CH4:D
@chad_d_stud_twitter
Jun 11 2018 06:17
hold on
Marcos Barbero
@marcosbarbero
Jun 11 2018 06:18
Ah ok
It’s not eureka, it’s spring cloud Config
CH4:D
@chad_d_stud_twitter
Jun 11 2018 06:18
kinda cool actually
oh yeah. you’re right
consul doesn’t have it though
but i’ve tested consul for two days and it’s actually simpler to work with, imo
i just don’t like the kv thing for its config
Marcos Barbero
@marcosbarbero
Jun 11 2018 06:20
Consul has its own storage
CH4:D
@chad_d_stud_twitter
Jun 11 2018 06:20
yeah, it’s a registry and a config server in one
Marcos Barbero
@marcosbarbero
Jun 11 2018 06:20
Yup
CH4:D
@chad_d_stud_twitter
Jun 11 2018 06:20
and it’s remarkabely easy to switch between the two
just config and build changes
CH4:D
@chad_d_stud_twitter
Jun 11 2018 14:01
is it possible to dynamically assign a value to name in Feignclient?
at run time
something like @FeignClient(name=“${runtime.value}”)
Marcos Barbero
@marcosbarbero
Jun 11 2018 14:04
don't get it wrong, but seems like you haven't tried yourself before asking, have you?
it's stated here in the docs whether placeholders are supported or not.
CH4:D
@chad_d_stud_twitter
Jun 11 2018 14:06
placeholders are for properties files
i’m still coding a PoC
so this is me “trying” :P
i’m trying to find some “understandable” code on how to set values programmatically
Marcos Barbero
@marcosbarbero
Jun 11 2018 14:12
I didn't mean you can't ask questions, it's totally fine to ask, ok? But the answer for your question is literally in the docs above
also, if you've added the place holder in your PoC and the matching property in the property files you could have found it out in maybe 1min? Maybe less?
CH4:D
@chad_d_stud_twitter
Jun 11 2018 14:13
i already know that’s possible
i want to know if it’s possible at runtime
which that stackoverflow answer seems to tell me otherwise
this is basically what i want to happen. i have a database of third party services (not part of our registry) with fixed REST endpoints. I want to design my controller in such a way that when someone passes a service code it would look it up in a database and then pass that value as name=“service-code” in the feign client
a one feign client to handle them all
Marcos Barbero
@marcosbarbero
Jun 11 2018 14:16
indeed, if you are planning to re-use the same feign client to connect to different services then the answer is no, you can not do it.
CH4:D
@chad_d_stud_twitter
Jun 11 2018 14:16
will the feign builder be any different?
it looks promising
Marcos Barbero
@marcosbarbero
Jun 11 2018 14:18
using the builder you can possible make it work, but have in mind that you gonna need to specify the target class for it on the fly
CH4:D
@chad_d_stud_twitter
Jun 11 2018 14:19
i’ll try it with a general use case for now
Marcos Barbero
@marcosbarbero
Jun 11 2018 14:20
if every api/call have the same target class then you're good to go, otherwise you'll have to work this around to dynamic switch the target as well
Patrick Cornelißen
@pcornelissen
Jun 11 2018 14:31
@shakuzen 4 days to go, let's see if this finchley release date will make it ;-)
Tommy Ludwig
@shakuzen
Jun 11 2018 14:36
@pcornelissen that reminds me, I should do some tests on the latest snapshots just to make sure the GA release doesn't have any surprises
Patrick Cornelißen
@pcornelissen
Jun 11 2018 14:41
For now I just used the latest RC2 release for the video course I'm creating for packt publishing ;-) But it would be neat to use the latest final version
CH4:D
@chad_d_stud_twitter
Jun 11 2018 15:06
@marcosbarbero looks like i got it somewhat working. I just don’t know how to use the encoder thing
Sushant
@bsushant-athena
Jun 11 2018 15:30
hi, is there any documentation or blog for zero downtime for eureka ? how netflix handles it?
because now to register to a service it takes min 30 sec
Patrick Cornelißen
@pcornelissen
Jun 11 2018 15:40
their cheap way out is saying that you always need a few instances running ;)
you can lower that time, but it makes eureka a little bite more fragile in terms of slight network or IO problems
CH4:D
@chad_d_stud_twitter
Jun 11 2018 15:44
i agree. even 30s isn’t enough if the network is slow and processing takes time
CH4:D
@chad_d_stud_twitter
Jun 11 2018 16:41
@marcosbarbero looks like this worked :smile:
@Autowired
    protected RestTemplate otherCaller;

    @RequestMapping("/test/{id}")
    public Object bankLoader(@PathVariable("id") long id) {
        MyRow row = testRepository.findById(id).orElse(new MyRow());
        return otherCaller.postForObject("http://" + row.getCode() + “/other", request, Result.class);
    }
Marcos Barbero
@marcosbarbero
Jun 11 2018 17:13
indeed, using RestTemplate is way easier to achieve what you want @chad_d_stud_twitter :smile:
Nils Wild
@NilsWild
Jun 11 2018 17:21
Hey i am using feign with an oauth2feignrequestinterceptor that uses clientCredentialResource details created by the spring security.oauth2.client properties that feignclient works fine until the token expires. As soon as this happens i get Unable to obtain a new access token for resource 'null'. The pr
ovider manager is not configured to support it. how can i fix this
Marcos Barbero
@marcosbarbero
Jun 11 2018 17:28
I do believe it will be easier to help you out if there's any sample code to check @NilsWild, otherwise it will be only guessing
Nils Wild
@NilsWild
Jun 11 2018 17:36
@marcosbarbero https://pastebin.com/LFK5PmCp very simple. I use keycloak an provided all the properties in security.oauth2.client. As i sasid it works as long as the token doesnt timeout
Marcos Barbero
@marcosbarbero
Jun 11 2018 17:39
by any chance, are you also using hystrix?
Nils Wild
@NilsWild
Jun 11 2018 17:43

@marcosbarbero yes

feign:
hystrix:
enabled: true

hystrix:
share-security-context: true

Marcos Barbero
@marcosbarbero
Jun 11 2018 17:45
do you get any exception?
Nils Wild
@NilsWild
Jun 11 2018 17:49
Caused by: org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException: Unable to obtain a new access token for resource 'null'. The provider manager is not configured to support it. at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.refreshAccessToken(AccessTokenProviderChain.java:182) at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainAccessToken(AccessTokenProviderChain.java:109) at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.acquireAccessToken(OAuth2FeignRequestInterceptor.java:171) at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.getToken(OAuth2FeignRequestInterceptor.java:127) at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.extract(OAuth2FeignRequestInterceptor.java:112) at org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor.apply(OAuth2FeignRequestInterceptor.java:100) at feign.SynchronousMethodHandler.targetRequest(SynchronousMethodHandler.java:158) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:88) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108) at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ... 27 common frames omitted
Marcos Barbero
@marcosbarbero
Jun 11 2018 18:22
maybe it's something related to keycloak
it's a different project but seems to be related, jhipster/generator-jhipster#6929
@NilsWild ^
Nils Wild
@NilsWild
Jun 11 2018 18:49
@marcosbarbero thanks but doesn't help actually it tries to refresh the token but i think the tokenproviderchain of oauth2ferigninterceptor kinda breaks it as with the clientcredentialsresourcedetails the refreshToken method should never be called as there is no refresh token flow
Marcos Barbero
@marcosbarbero
Jun 11 2018 19:32
Yeah, you are right
Nils Wild
@NilsWild
Jun 11 2018 20:04
@marcosbarbero i fixed it by modifying the constructor of Oauth2feignRequestInterceptor to use the clientscretendialsresourcedetailsprovider directly instead of the providerchain
Marcos Barbero
@marcosbarbero
Jun 11 2018 20:46
Nice