-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Communication between two microservices #3649
Comments
@xetys wrote an article which had a section dealing with this check this http://stytex.de/blog/2016/03/25/jhipster3-microservice-tutorial/ |
ping @sdoxsee @PierreBesson |
Thanks @deepu105 |
Note that there is a module that can help you generate your clients. It's not based on RestTemplate but on Netflix's Feign so it should be easy to plug Ribbon/Eureka. |
Thanks @cbornet |
Great article @xetys ! Ping me on Twitter next time, so I know and can RT you! |
Hi @MBenali, maybe you can take a look of what I did here: https://github.com/PierreBesson/jhipster-circuit-breaker-demo using Feign as a Rest client for microservices. |
Thanks to all MBenali |
I didn't code yet the swagger template for microservice using @FeignClient but I think the current swagger-cli module should work well with spring cloud's autoconfiguration of Ribbon. @Bean
public FeignApiClient FooRibbonApiClient() {
FeignApiClient apiClient = createApiClient(FooApiClientProperties, feignEncoder, feignDecoder);
apiClient.getFeignBuilder().client(feign.ribbon.RibbonClient.create()); // or better: create a RibbonClient bean
apiClient.setBasePath("http://foo");
return apiClient;
} |
i am currently stuck in upcomming-deadline-phases.....I have the following in mind...
i was trying Netflix Feign yesterday but i was really stuck on configuring the oauth2 behaviour. Since I am not familar with feign so far, I would appreciate some help from anyone who knows it in detail. Otherwise I could share my dirtyhacking workaround to passs access tokens to feign... or simply use OAuth2RestTemplate |
thanks @cbornet, I will try that out |
@xetys, I think Feign integration with OAuth2 is already merged here: spring-attic/spring-cloud-security@2718a04 I was thinking that we should a similar Feign Request Interceptor for JWT. |
@PierreBesson, i am thinking of finding an hour, maybe together with @cbornet, to wire things in a right way. i believe this would be quite fast, because it would take me some more time to figure out the best practice (I started using spring just some months ago 😆) |
ok, couldn't hold myself and figured out....thanks to @PierreBesson hinting me there is already a spring side interceptor....so all you need is actually define a OAuth2ProtectedResourceDetails an declare the interceptor bean like this: @Bean
public RequestInterceptor getOAuth2RequestInterceptor() throws IOException {
log.info("installing OAuth2 request interceptor to feign");
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), geOAuth2ProtectedResourceDetails());
} and that's it! I PR all what is needed the next days... |
so feign clients can be added declarative to. This is a requirement for the next step of a JHipster feign client subgenerator. for feature request jhipster#3649
Hi @xetys I want to find an information for the microservice reception_ms by REST calling the microservice reference_ms The modifications in my code: in microservice : reception_ms i add the classes :
in the Referentiel_Gateway, i add @EnableCircuitBreaker to the ReferentielGwApp (I have to make the same thing on the second Gateway: Reception_GW ? ) in the microservice : Referentiel_ms, i modify MicroserviceSecurityConfiguration (.antMatchers("/api/**") //FOR TESTING!, ... ) here is the exception which I obtained
|
@MBenali is "referentiel_ms" the name appearing in eureka? |
@xetys yes referentiel_ms is the name appearing in eureka, i add the @EnableCircuitBreaker to the second Gateway (ReceptionGwApp) , and now i retrieve (discover) my microsservice, but i obtain this exception:
|
@MBenali this is the time where 404 means something good...it least you are connected to your service and the url is not correct. Maybe we proceed this talk in a chat like gitter? I am afraid of spamming this issue forum a bit 😄 |
Ok, @xetys |
@xetys @PierreBesson I added an option in swagger-codegen to generate a stub interface like what is described here. Would you help me test it before I PR ? @FeignClient(name="pet", url="http://petstore.swagger.io/v2")
public interface PetClient extends PetApi {
} |
@cbornet, It's a very interesting solution. I did some testing with your branch but only on the petstore. I will try to use it on my Feign Circuit Breaker demo to see if it works in this case. Do you know if Hystrix fallbacks will be available even if not using Ribbon/Eureka ? |
Yes it's my fault 😄 . I have fixed the tests now. From what I understand Ribbon is always used with FeignClient (with or without Eureka). |
Just had it working on a monolith app. This is just awesome ! I'll upgrade my module asap as it's much more integrated and flexible than what I had done ! |
There is an issue with petstore endpoints that have multiple "produces" (spring-cloud/spring-cloud-netflix#808). I'll see how this can be dealt. |
@PierreBesson I confirm it works with Hystrix without Eureka. Hystrix is even enabled by default on my monolithic test app. |
@cbornet I just did some more tests today with your branch codegen.jar and JHipster Microservices and its really promising as we only have to generate the @FeignClient class. |
That's a really good news. Did you try to do a fallback using Hystrix using : |
Arf ! I have this issue : spring-cloud/spring-cloud-netflix#1023 |
mhm....i hadn't any problems in my setup where the feign client are also using @RequestMapping as well.... |
Does it still work when you add the Hystrix fallback ? |
See spring-cloud/spring-cloud-netflix#466 (more explicit) |
@cbornet, I confirm that it doesn't work with an interface generated by your swagger-codegen. As soon as I add the fallback it fails to launch. |
I fixed it (removed the RequestMapping on the interface and adjusted the path in the methods). Can you check ? |
@cbornet, the spring-cloud/spring-cloud-netflix#1023 issue is now fixed and released in Brixton SR1. I have made PR to upgrade. Please tell us if it helps with your problem. |
I don't think it really fixes the issue. The problem is in spring-framework so I don't think it can be solved. |
@PierreBesson @xetys I have updated the swagger-cli module to use the spring-cloud-feign codegen. Would you make some tests before I publish to npm ? |
I've used the org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor in the past and it has worked well for me. However, in my current project I'm not using OAuth2, just JWT. What would be nice would be to have the ability to use either and have JHipster generate the necessary classes and configuration to do that. Any feelings about that? Thanks, Russ Baker |
@cbornet yes, i got a pretty stack of things to do on this and on that but due to a tight schedule I just had not the time....I issued to return to our feign problems during the next week @russTbaker For me its some conceptional problem, because there is no support of a pure maschine recognition for internal calls using that mechanism. The only thing you can do here is to pass the jwt from request if possible, so internal requests are threated as similar to your gateway requests. This at least is limiting the security options with pure jwt, as well as centralizing to much responsibility on the gateway...as I see it... if you still want to go this way, @PierreBesson already started an approach of using a JwtRequestInterceptor. I take a look as soon I solve my issues on that topic |
Closing as I think the question is answered... |
How to make Comunication between two microservices (microservices are generated with JWT security)
Hi,
In the first, I note that hhis is not a bug, but I did not know where to make my request
Used JHipster (v3.1.0) to generate 2 microservices (2 gateway and 2 microservices, with JWT security):
1st composant) Reference component "ref_gw" gateway app and "ref_ms" : microservice
2nd composant) "Reception_gw" : gateway app, and "reception_ms" microservice
Our need: the microservice "reception_ms" has to verify certain data which are quoted ref_ms, (by REST GET or POST Method)
I saw some documentations (theory only) speaking of discovery server-side (or the passage by the registery, other on spring cloud and AMQP,...), but how to implement it (registery solution) I found nothing.
Thank you
The text was updated successfully, but these errors were encountered: