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

25th
Jan 2016
Dreampie
@Dreampie
Jan 25 2016 02:54
spring-cloud/spring-cloud-netflix#782
@FeignClient return Page can not deserialization
Dreampie
@Dreampie
Jan 25 2016 09:19
The same class name of two @FeignClient in different packages,can't @Autowired
spring-cloud/spring-cloud-netflix#790
Dave Syer
@dsyer
Jan 25 2016 09:28
@Dreampie if you want to discuss an issue before raising it, you can do so here.
There's no need to cross post
Dreampie
@Dreampie
Jan 25 2016 09:32
ok,I understand,I just want to solve this problem as soon as possible
Dave Syer
@dsyer
Jan 25 2016 09:33
You could help by explaining your problems a bit more
Mostly your posts don't make sense because they don't have full information, steps to reproduce, sample projects etc.
Dreampie
@Dreampie
Jan 25 2016 09:42
This is very simple, if there are two classes of the same name, there are different packages, use @ FeignClient,@ Autowired will report an error
package demo.service;

@FeignClient("example-service")
public interface Demo {
}
package demo;

@FeignClient("demo-service")
public interface Demo {
}
@Autowired Demo demo;//use anyone
Dave Syer
@dsyer
Jan 25 2016 09:44
Great, thanks. I think that one was clear, but I haven't tried to reproduce it yet.
You can just use a different class name as a workaround, so it doesn't see urgent
Dreampie
@Dreampie
Jan 25 2016 09:49
I really need, because these FeignClient interface has been defined in the project ahead of other sectors, if renamed, I have to define myself these interfaces, too much trouble
Dreampie
@Dreampie
Jan 25 2016 09:56
and another question,
```

how can use model in GET method,like this:

@FeignClient("serviceId")
public interface NoticeService {
   @RequestMapping(value = NoticeConstants.NOTICES_PATH, method = RequestMethod.GET)
   ResponseEntity<List<NoticeEntity>> findAll(@RequestParam("entity") NoticeEntity entity);
}

i found feign-parameter-processors,but not found docs and example

Dave Syer
@dsyer
Jan 25 2016 10:13
A @RequestParam can't be a NoticeEntity
Read the Spring MVC documentation
that's where these annotations come from
Dreampie
@Dreampie
Jan 25 2016 10:16
spring-cloud/spring-cloud-netflix#619
annotation processor can custom annotation to support,but no example
Dave Syer
@dsyer
Jan 25 2016 10:45
We already support @RequestParam
so it wouldn't be a custom annotation
You can look at the implementation as a sample (the source code is open)
But it won't help you because @RequestParam can only be a simple type (String, int etc.)
You have to be able to encode it in a query parameter.
Dreampie
@Dreampie
Jan 25 2016 11:42
How to do,Can you provide an example of it?
Dreampie
@Dreampie
Jan 25 2016 12:26
@dsyer
Dave Syer
@dsyer
Jan 25 2016 13:46
An example of what, sorry?
Sergei Egorov
@bsideup
Jan 25 2016 14:44

Hey =) Since this project was inspired by Spring Cloud Config, I've decided to share it here as well, because it extends some Spring Cloud Config ideas for any app, not only SB ones:

https://github.com/zeroturnaround/configo

(Sorry if it's not relevant here)

Tommy Ludwig
@shakuzen
Jan 25 2016 14:50
@bsideup Looks quite interesting. Thank you for sharing.
Alex Filatov
@sprgn
Jan 25 2016 16:01
Is spring-cloud-consul the only way to implement distribute sessions?
Dreampie
@Dreampie
Jan 25 2016 16:03
@dsyer feign annotation processor
support complex model not only string int
need example
Dave Syer
@dsyer
Jan 25 2016 16:06
I don't think there is one
HTTP requests don't really support complex objects in the query
You should probably just use a POST and a @RequestBody
or stick to simple objects in queries
Dreampie
@Dreampie
Jan 25 2016 16:08
but REST not recommended
Dave Syer
@dsyer
Jan 25 2016 16:09
I don't know what you mean.
Dreampie
@Dreampie
Jan 25 2016 16:11
if query has too many parameter,its better to package a model
Dave Syer
@dsyer
Jan 25 2016 16:11
I guess that's what I said
Or maybe you just want to bind to a form bean
(which is not a @RequestParam)?
Dreampie
@Dreampie
Jan 25 2016 16:14
and REST recommened use GET method ,so i want use FeignClient with model parameter
like @Model User user
Dave Syer
@dsyer
Jan 25 2016 16:15
I think you can use POST for anything if you want to. You just have to be explicit about what it is doing.
I don't think we have any support for @ModelAttributein Spring Cloud Feign. I'm not even sure it is possible, but if it is you can try it I guess.
Dreampie
@Dreampie
Jan 25 2016 16:19
spring-cloud/spring-cloud-netflix#609
spring-cloud/spring-cloud-netflix#619
Dave Syer
@dsyer
Jan 25 2016 16:19
#609 is a different annotation that we don't support
#619 is already merged
Dreampie
@Dreampie
Jan 25 2016 16:21
spring-cloud/spring-cloud-netflix#617
like this custom annotation and type?
Dave Syer
@dsyer
Jan 25 2016 16:21
#617 is probably relevant for your use case
But it's still open
(i.e. no-one contributed a fix yet)
Dreampie
@Dreampie
Jan 25 2016 16:24
RESTful recommended use GET for query,if has too many parameter best way to pack model,can use name=json
Dave Syer
@dsyer
Jan 25 2016 16:25
JSON is pretty crazy in a query param
You are better off using POST, seriously
Dreampie
@Dreampie
Jan 25 2016 16:29
I like GET and JSON,spring boot with argumentResole can resolve this,Feign Client can not?
Dave Syer
@dsyer
Jan 25 2016 16:29
Spring MVC does not support JSON in query params out of the box as far as I know
Dreampie
@Dreampie
Jan 25 2016 16:32
springMVC HandlerMethodArgumentResolver
custom support
Dave Syer
@dsyer
Jan 25 2016 16:34
Sure you can customize it
You can customize Feign as well
It doesn't make it idiomatic
Dreampie
@Dreampie
Jan 25 2016 16:34
Feign client can support modelAttribute?
Dave Syer
@dsyer
Jan 25 2016 16:35
Don't know. Probably.
"model" is a bit of a strange concept for a client
but it can probably be bent into shape
Dreampie
@Dreampie
Jan 25 2016 16:38
but it can make
the
code more friendly
Dave Syer
@dsyer
Jan 25 2016 16:39
I agree it would be preferable to JSON in a query param
Dreampie
@Dreampie
Jan 25 2016 16:42
Haha so you will support model with GET in FeignClient?
Dreampie
@Dreampie
Jan 25 2016 16:49
@FeignClient("serviceId")
public interface NoticeService {
@RequestMapping(value = NoticeConstants.NOTICES_PATH, method = RequestMethod.GET)
ResponseEntity<List<NoticeEntity>> findAll(@JsonArgument("entity") NoticeEntity entity);
}
Dave Syer
@dsyer
Jan 25 2016 16:50
JSON just doesn't fit with a GET IMO
So I don't expect that feature will be part of Spring anything
@ModelAttribute might be possible
I haven't really thought about it
Dreampie
@Dreampie
Jan 25 2016 16:52
ok,ModelAttribute pretty good also
if there are two classes of the same name, there are different packages, use @ FeignClient,@ Autowired will report an error
Dave Syer
@dsyer
Jan 25 2016 16:54
I know. I saw the issue you raised.
Dreampie
@Dreampie
Jan 25 2016 16:56
Yes,are you reproduce it?
Dave Syer
@dsyer
Jan 25 2016 16:57
Not yet. I don't doubt it's an issue though.
Dreampie
@Dreampie
Jan 25 2016 16:58
If you have completed these
Tell me
Dave Syer
@dsyer
Jan 25 2016 17:00
Github will notify you
Feel free to send pull requests
Dreampie
@Dreampie
Jan 25 2016 17:02
thanks,
It's too late,I went to bed
Alex Filatov
@sprgn
Jan 25 2016 18:36
Does anyone have a suggestion for the best approach to implementing distributed sessions with spring-cloud-*? consul? netflix? etc.?
Dave Syer
@dsyer
Jan 25 2016 19:14
What's wrong with Spring Session?
Alex Filatov
@sprgn
Jan 25 2016 19:16
Nothing, just wanted to know spring-cloud's take on this. Thanks.