-
-
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
Do not allow relationship between entities in different microservices #9949
Comments
Totally agree we should not allow relations between entities of different services/apps. |
Personally I think it is a bad idea to allow relationship between different microservices. This would qualify as an instance of the "entity service anti pattern" : https://www.michaelnygard.com/blog/2017/12/the-entity-service-antipattern/ |
If we would allow that, the good pattern would be really complicated to be abstracted in JH: Let's take a service A with an entity a When saving 'a', it should send a message in a queue catched by B which duplicates the data in it's own 'a' table... When I have to make that kind of antipattern with JH, I usually duplicate the same entity twice with a different name, do not generate entities on the consumer side and then make the join with a feign call in service. In order to ease this procedure (if requested by users), it would be nice to introduce some new behaviour on entity generation:
|
@atomfrede I hope you meant "not allow"? |
Of course 😃 it's to warm for such things.
…On Fri, Jun 21, 2019, 19:33 Deepu K Sasidharan ***@***.***> wrote:
@atomfrede <https://github.com/atomfrede> I hope you meant "not allow"?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9949?email_source=notifications&email_token=AABRVCN2SJPJKEZ7PBHAQDTP3UGGXA5CNFSM4HZQ3DO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYJC6JY#issuecomment-504508199>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABRVCKH7D3IMHUPP3MIJT3P3UGGXANCNFSM4HZQ3DOQ>
.
|
FWIW, our current OAuth + microservices implementation does not create relationships between microservices. Each microservice has its own |
Agree with you, I think we should "not allow" |
The JDL already forbids this, so this is a big +1 from me. |
I've a different opinion about this topic. From a model perspective it's not an anti pattern sharing entities between micro services as long as they are used only to "consume" data provided by another service. The bad practice is sharing entities and maintaining such code manually which is against the DRY principal and creates dependencies between APIs. But when code replication is made by a generator (which is one of the purpose of having a “model-based-generation” approach) it's not a bad practice at all. The generator could generate the code in a separate folder (generated/... or src-gen/... etc.) and a service can so consume data provided by another API without having a dependency on code level. |
Hi, I agree to distinguish between a 'A' consumer (dto + feign client) part and a 'B' provider part (which is the micoservice which manage the B entity itself) as an option provided by the generator. It should be useful in many business cases (cf @Tcharl post) 3 solutions :
As a conclusion I suggest that the generator provides 2 options :
|
As mentionned here #9287 (comment) :
So yes, it's possible with Kafka |
@pascalgrimaud so, does this mean we're gonna allow relationshps as long as the architecture is event-driven and forbid when it is not? |
@MathieuAA : my idea is not really to allow relationships between microservices but to duplicate the common table between 2 microservices.
Exact. Right now, I'm short on time, but I'll detail my idea in a specific ticket with Kafka soon, so we can discuss about it |
Just coming here from #7424 From a bit of googling it looks like Debezium might be a good fit here with Kafka. It could be used not only to keep entities in sync across microservices but also for the Elasticsearch data replication which would fit nicely into jHipster too as it provides the elasticsearch layer. Maybe it's not good fit as i'm not super familiar with jHipster architecture but just said I'd throw it out there. |
I think especially Embedded Debezium could be a good fit for JHipster : https://debezium.io/docs/embedded/ |
Cool, i might give it a shot during the week. |
It's opened for too long and no more discussion on this ticket. Then, to resume:
So let's close this |
Definitely what i was looking. Thank you for amazing work guys. |
Seems like currently, we allow relationships to be created between entities belonging to different microservices(Need to be double checked, but based on #8920 we allow it at least for the user entity)
IMO we shouldn't allow this as it has many architectural issues as well as practical tech issues
-The entity data gets duplicated across services and it's hard to keep them in sync.
@jhipster/developers WDYT?
If we decide not to allow this we need to do below
The text was updated successfully, but these errors were encountered: