3

we used microservice architecture of jhipster and generated three applications uaa, microservice, gateway. then run uaa and jhipster registry on a server, also we have some full stack developers who want to develop both gateway and microservice at the same time.

then, they deploy their microservice and gateway on jhipsterRegistery which is located on remote server. Because of the same name of microservices, jhipsterregistery can not handle requests from gateway to the right microservice

how to manage this problem?

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49

2 Answers2

1

We had the same problem and solved our issue by using a variable as a microservice application name. Then changed all rest URLs in gateway with this variable. So each developer just needs to change appname in application.yml in micro the same as the variable in app.constants.ts in the gateway as well.

Hosi Jafari
  • 88
  • 2
  • 9
0

Sharing registry and gateway is probably a bad idea. Full stack developers should run the gateway and registry locally on their PC, only share UAA if you really want to share something.

If you still want to do it, you could get inspired by how to manage multiple versions of a web API on a gateway. After all, in your case, each developer wants to use his/her own version of the API.

  • From client side, this can be done through URL or through an HTTP header. This means that you are able to configure client code to require a specific version.
  • This extra information in request would then get used by gateway for routing to the service that matches the requested version.
  • This works only if Zuul proxy in gateway knows about which version is supported by which service instance. It means that each instance must add this version information to their Eureka regsitration.

Here are 2 ideas that you could try:

  1. version in URL: define a spring profile (e.g. user) and use it to set a different application name in bootstrap-user.yml
  2. version in header: add some property to Eureka metadata map (eureka.instance.metadataMap in bootstrap.yml) and modify the gateway so that it uses this info for routing.

Have a look at Spring Cloud Eureka server docs to get a good understanding about how this works and you could get even better ideas.

Here is an article about API versioning that could inspire you too: https://tech.asimio.net/2017/03/06/Multi-version-Service-Discovery-using-Spring-Cloud-Netflix-Eureka-and-Ribbon.html

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49
  • Thank you for your answer, running 4 application(registry, uaa, microservice, gateway) take more resources on developer's PC. Because of that we run registry and uaa on server , and just microservice and gateway run on their PC. I will try the solution that you suggested. – Leila Mollaei Feb 03 '20 at 07:08
  • If you have correctly set the JVM memory options of your apps, resource consumption should not be a problem. If your PCs don't have much resource then why choosing a microservice architecture? – Gaël Marziou Feb 03 '20 at 09:40
  • Jhipster has provided this ability to run registry and uaa on server and connect to that from local. Moreover, related to the distributed systems knowledge, we thought this solution is more rational. – Leila Mollaei Feb 03 '20 at 10:19