首先,我爲我的項目使用JHipster 4.0.x。我正在使用微服務架構。兩個微服務之間的通信架構
對於這個例子,我有一個網關,一個用於「Store」的微服務,另一個用於「Skill」。 我想將所有商店集中在一個數據庫中,並將技能集中在第二個數據庫中。
每一個數據存儲庫都不會以相同的速度進化。另一方面,它們將成爲我的基礎架構的中心點,以便通過ESB更新其他軟件。
Jhipster非常棒,我很輕鬆地爲每項服務提供了我的CRUD。
棘手的問題是商店是由技能定義的。最簡單的方法就是說我只用「技能」和「存儲」做一項服務。但我不能這樣做,因爲「技能」也必須成爲其他數據的中心點。
我想象這個實體的架構
[技巧]
[STORE] ----多到一個---- [LINK_WITH_OTHER_ENTITIES]
(帶*號以.json通過產生jhipster):
上技能服務:
- 實體技能
{ "fluentMethods": true, "relationships": [], "fields": [ { "fieldName": "code", "fieldType": "String" }, { "fieldName": "libelle", "fieldType": "String" } ], "changelogDate": "20161201084915", "dto": "no", "service": "no", "entityTableName": "filiere_metier", "pagination": "no", "microserviceName": "metiers", "searchEngine": "elasticsearch" }
上存儲服務:
- 實體店
{ "fluentMethods": true, "relationships": [ { "relationshipName": "categorie_metier", "otherEntityName": "pont_msvc", "relationshipType": "many-to-one", "otherEntityField": "id" } ], "fields": [ { "fieldName": "code", "fieldType": "String" }, { "fieldName": "lib", "fieldType": "String" } ], "changelogDate": "20161125141916", "dto": "no", "service": "no", "entityTableName": "store", "pagination": "no", "microserviceName": "store", "searchEngine": "elasticsearch" }
- 實體做出鏈路與技能
{ "fluentMethods": true, "relationships": [], "fields": [ { "fieldName": "idext", "fieldType": "String" }, { "fieldName": "msvcName", "fieldType": "MicroServices", "fieldValues": "gw,metier" }, { "fieldName": "msvcEntityName", "fieldType": "String" } ], "changelogDate": "20161208100401", "dto": "no", "service": "no", "entityTableName": "pont_msvc", "pagination": "no", "microserviceName": "store", "searchEngine": "elasticsearch" }
然後當我CRUD的商店,我會從技能使用CRUD太感謝this article不過這點是另一回事。
您認爲如何?這是正確的方式嗎?
感謝這個反應存在不預建功能。 –
感謝您的迴應。我同意你對服務依賴關係的論點。這也是我的想法。但是,在兩種服務之間存儲數據鏈接的最佳做法是什麼? –