简体   繁体   中英

expose jhipster microservice client classes

I have two micro services created with jhipster. (ms1 and ms2)

I have used AuthorizedFeignClient to communicate between two micro services.

ms1 has some DTO classes which are used as input and output classes for REST APIs.

from ms2 I need to call some API of ms1, and hence I need those DTO classes(POJOs) for input and output data.

These DTO classes are obviously not there in ms2.

So I have two options in my mind currently:

1) copy DTO classes from ms1 to ms2

2) import ms1 as maven dependency in ms2

Approach 1 - seems easy, but there will be duplicate code.

Approach 2 - ms1 and ms2 both are packaged as war file and not as jar file. It doesn't look good to include whole war file just to use some classes.

What are the other Approach I should take to get those DTO classes from ms1 to ms2 ?

If you search about microservices architecture, you'll find that much people recommend to share nothing between microservices as you want to be able to evolve them independently as much as possible. This means that your approach 1 is preferred, you could add a 3rd approach which is to generate your REST client code from swagger JSON spec . JHipster has a module for doing so: https://github.com/cbornet/generator-jhipster-swagger-cli

Also communication between services is usually something to consider carefully, it could be an indication that your service boundaries are wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM