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

25th
Feb 2016
Fabian Wallwitz
@cforce
Feb 25 2016 00:15
I use an interface class from server side.jar on client side for my @FeignClient . The client interface just extends the server interface and has a @FeignClient anotation. But starting my spring booot client service i got spring mvc errors. I had to move my @RequestMapping from server side interface to sevice side implementation (while keeping @RequestMapping in same interface at method level). Therefore the @FeignClient (not maling use of the interface level base url by extension) needs the url replicated with same url like @RequestMapping from service impl- in the @FeignClient anotation. The problem is that Sprng MVC instatiates a Proxy for the Endpoints (because of the @RequestMapping anotation) and @FeignClient also does, where this two beans clashes.
On CLient side i don't import vthe service impl. only the service interface ..thats the reasons mvc does not find this @RequestMapping() and creates aproxy which collidates with the one for the FeignCLient.
Any idea how to solve this more elegant?
Matt Benson
@mbenson
Feb 25 2016 00:15
now technically if your problem is what I think it is, it is more of a spring-boot issue
Spencer Gibb
@spencergibb
Feb 25 2016 00:15
Was there are @RequestMapping on the top level?
Fabian Wallwitz
@cforce
Feb 25 2016 00:15
yep
base urls for all methods
Matt Benson
@mbenson
Feb 25 2016 00:16
and you are using parameter annotations on the methods?
Fabian Wallwitz
@cforce
Feb 25 2016 00:16
yep
Matt Benson
@mbenson
Feb 25 2016 00:16
I have a local workaround cooked up with @dsyer if you are interested
however, the local version of my code uses Java 8 and Apache Commons Lang 3
Fabian Wallwitz
@cforce
Feb 25 2016 00:17
you mean one thats need spring cor lib modifications?
Matt Benson
@mbenson
Feb 25 2016 00:18
the local workaround uses spring-boot facilities to work around the problem in a compatible manner, i.e. without modifying Spring proper
Fabian Wallwitz
@cforce
Feb 25 2016 00:19
sound interesting .. curretly my workaround is to copy the base url in service impl and FeigClient
Matt Benson
@mbenson
Feb 25 2016 00:20
don't you have to copy all the parameter annotations to the service impl as well?
Fabian Wallwitz
@cforce
Feb 25 2016 00:20
.. i just chedk .. till now the classes which uses the feign clients do't have parama anotations so far .. but i need to use them as well ..
i think i will ran into this too soon
is your cod for the workaround online?
i would like to have a look into
Matt Benson
@mbenson
Feb 25 2016 00:22
well, I have pasted into the spring-boot gitter before
added imports
Matt Benson
@mbenson
Feb 25 2016 00:28
HTH
Fabian Wallwitz
@cforce
Feb 25 2016 00:35
i would have checked if Feign in interitance and then don't create then bean for Mvc -- - sophisticated.. only a glue ..what you are doing..
Matt Benson
@mbenson
Feb 25 2016 00:35
is that good or bad?
Fabian Wallwitz
@cforce
Feb 25 2016 00:36
can't say -- if it works .. its always good for me .. but can you explain in a few word what you hav tweaked?
at the end you can extend any MVC enriched interface with Feign ..without getting problems?
ahh .. here is ur comment spring-projects/spring-framework#976
Matt Benson
@mbenson
Feb 25 2016 00:43
well, unless I've misunderstood you, Feign isn't really the problem. Feign understands your interfaces fine, but Spring MVC can't get the parameter information from the implementation methods because parameter annotations aren't inherited. The InheritanceAwareMethodArgumentResolverWrapper simply walks up the method override hierarchy to find the parameter definition that actually carries the annotation. You could probably tweak the BeanPostProcessor to only wrap resolvers that extend AbstractNamedValueMethodArgumentResolver
and, of these, be careful of RequestParamMethodArgumentResolver... its implementation is a bit more complicated than the others
gtg
Fabian Wallwitz
@cforce
Feb 25 2016 00:50
tx .. maybe i will contact you again ..hopefully the support to use of a Spring-annotated REST interface for client and server alike will be improved
checketts
@checketts
Feb 25 2016 00:54
Thanks for the file locking tip @spencergibb I'll create a pull request with my approach.
Spencer Gibb
@spencergibb
Feb 25 2016 00:58
@checketts nice!
checketts
@checketts
Feb 25 2016 00:59
Is apache commons-pool available in spring?
Or would I make my bean be conditional on that class?
Spencer Gibb
@spencergibb
Feb 25 2016 01:01
no, it’s not. hmm
checketts
@checketts
Feb 25 2016 01:02
I see CommonsPool2TargetSource in spring-aop but looks like it leverages commons-pool
Spencer Gibb
@spencergibb
Feb 25 2016 01:05
I wonder if you could use something from java itself like Executors.newFixedThreadPool(int nThreads) https://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
checketts
@checketts
Feb 25 2016 01:06
I try that approach
Spencer Gibb
@spencergibb
Feb 25 2016 01:07
Spring has a ThreadPoolTaskExecutor
checketts
@checketts
Feb 25 2016 01:08
Thanks again
Spencer Gibb
@spencergibb
Feb 25 2016 01:08
something that doesn’t have an external dependency will get by @dsyer quicker ;-)
checketts
@checketts
Feb 25 2016 01:10
Same for @westse ;)
Spencer Gibb
@spencergibb
Feb 25 2016 01:10
:laughing:
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:03
Hi everybody, I’m playing with Spring Cloud Config Server and client, at server I’m doing a multiple repos configuration, a default one for production environment and some others for development, staging and so on. The server side is just fine, I’ve a doubt about the client, is there any param to set on client to make it get the proper configuration repo from the server? I just made it work with spring.application.name patterns but I would like to keep the same application name for all environments
Spencer Gibb
@spencergibb
Feb 25 2016 16:05
A few options, different repo’s for prod vs staging vs dev (this has a better security story), different labels (branches in git) or spring profiles.
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:07
I was using a single repository for all environments with different labels (git branches), but now I need to move production environment for a new private repository with restrict access
Spencer Gibb
@spencergibb
Feb 25 2016 16:09
Then a different repo
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:09
At server side I just configured the repositories, but I just don’t know how to use them from client side without use the spring.application.name pattern
Dave Syer
@dsyer
Feb 25 2016 16:10
Don't you use a different profile in production?
Or a different label?
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:10
I was just playing with different labels
Dave Syer
@dsyer
Feb 25 2016 16:11
There is also spring.cloud.config.name (from memory) (which can be different to spring.application.name)
Spencer Gibb
@spencergibb
Feb 25 2016 16:11
Shouldn't require much change, if any. If your prod repo has the same branches and file names. Am I missing something?
Dave Syer
@dsyer
Feb 25 2016 16:11
You have to have something that is different between the environments
Spencer Gibb
@spencergibb
Feb 25 2016 16:12
Is this being served from the same config server?
Dave Syer
@dsyer
Feb 25 2016 16:12
Either a client config setting, or a different server.
Spencer Gibb
@spencergibb
Feb 25 2016 16:12
:+1:
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:12
@spencergibb it’s the same config server
Is a better approach play with 2 config servers? One for dev phase and another on for production?
Dave Syer
@dsyer
Feb 25 2016 16:13
I think so
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:14
@dsyer @spencergibb Thank you both.
Spencer Gibb
@spencergibb
Feb 25 2016 16:14
For wanting better security, using the same config server let's other environments read prod data, if your OK with that.
Missed those few messages above :smile:
Marcos Barbero
@marcosbarbero
Feb 25 2016 16:16
I’ll build a second configserver for development, local and staging phases
it will fit :)
Fabian Wallwitz
@cforce
Feb 25 2016 16:58
i want to discovery services on consumer side via custom filter logic (included in a client jar using the discovery client under the hood) which is based on keys of the producer (delivered via the metadatamap) ...is this a good idea.. and is there som best pratice/example howto do that?
Matt Benson
@mbenson
Feb 25 2016 16:59
@cforce hi again
Spencer Gibb
@spencergibb
Feb 25 2016 17:01
Dave Syer
@dsyer
Feb 25 2016 17:14
Hi @mbenson
Matt Benson
@mbenson
Feb 25 2016 17:15
hi @dsyer
Dave Syer
@dsyer
Feb 25 2016 17:17
You still have that thread local PR hanging open, right?
The one I reverted
Matt Benson
@mbenson
Feb 25 2016 17:17
I do
@cforce : the link @spencergibb posted is interesting. I did something similar by extending EurekaDiscoveryClient and post-processing the original EurekaDiscoveryClient @Bean, replacing with the subclass (necessary because the original bean is not conditional). Then I repeated the process for ribbon by extending DomainExtractingServerList and returning from my Ribbon configuration.
@dsyer I guess I will open a Feign issue as discussed in that gitter room as well. I have no idea what their turnaround would look like. I'm also allergic to gradle so no idea whether I'd be able to produce a patch... my luck building gradle projects is very hit-or-miss.
Dave Syer
@dsyer
Feb 25 2016 17:21
I'm the same FWIW
Matt Benson
@mbenson
Feb 25 2016 17:21
nice to know ;)
we had talked about the possibility of switching from ThreadLocal to static but I had wondered whether that would pose potential problems for multiple Feign contexts/JVM. Is there any other obvious Spring-specific possibility of which I am just not aware?
Dave Syer
@dsyer
Feb 25 2016 17:23
Not that I know of
Matt Benson
@mbenson
Feb 25 2016 17:26
is there anything we could dream up for NamedContextFactory and ThreadLocal to make available the initializing context?
Spencer Gibb
@spencergibb
Feb 25 2016 17:26
@adriancole seemed amenable to a feign change that would allow us to inject
Matt Benson
@mbenson
Feb 25 2016 17:27
right, I just tend to assume that a PR will get tended to more quickly than an open request.
guess I can fork Feign and see if I can build it
Spencer Gibb
@spencergibb
Feb 25 2016 17:27
I can (and I seem to have similar gradle allergies as @dsyer)
Matt Benson
@mbenson
Feb 25 2016 17:28
I was able to build spring-framework, but not Eureka. The latter was disappointing because I wanted to try shading their jersey-1 dependency and make jersey-2 available in spring-cloud w/ Eureka. :/
Spencer Gibb
@spencergibb
Feb 25 2016 17:29
hmm, I did it in the last few days. Eureka needs java8
Matt Benson
@mbenson
Feb 25 2016 17:29
I could try it again
I was an active Ant committer (still a committer, just no longer active) when gradle was first created, and I never approved of its initial approach of using Ant tasks just because, being familiar with those, I knew they were designed specifically to be wrapped and not directly manipulated. Gradle has of course matured since then but I just never did warm to it.
Matt Benson
@mbenson
Feb 25 2016 17:37
okay, magically Eureka builds for me now. Nice