I use directly a .jdl file in order to generate a microservice project.
I have gateway and three microservices. My simplified jdl file:
application {
config {
baseName projectName,
reactive false, //I tried to enforce this, although I know the default value is already false
applicationType gateway,
packageName com.ritan.projectName.gateway,
authenticationType jwt,
prodDatabaseType postgresql,
clientFramework react,
buildTool maven,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
testFrameworks [cypress],
serverPort 8085
}
entities
/* from first microservice */
A, B, C,
/* from the second microservice */
D, E,
/* from the third microservice */
F, G
}
application {
config {
baseName firstMicroservice,
reactive false,
applicationType microservice,
packageName com.ritan.projectName.firstMicroservice,
authenticationType jwt,
prodDatabaseType postgresql,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
serverPort 8081
}
entities A, B, C
}
application {
config {
baseName secondMicroservice,
reactive false,
applicationType microservice,
packageName com.ritan.projectName.secondMicroservice,
authenticationType jwt,
prodDatabaseType postgresql,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
serverPort 8082
}
entities D, E
}
application {
config {
baseName thirdMicroservice,
reactive false,
applicationType microservice,
packageName com.ritan.projectName.thirdMicroservice,
authenticationType jwt,
prodDatabaseType postgresql,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
serverPort 8082
}
entities F, G
}
entity A {
/* some values */
}
entity B {
/* some values */
}
entity C {
/* some values */
}
entity D {
/* some values */
}
entity E {
/* some values */
}
entity F {
/* some values */
}
entity G {
/* some values */
}
/* Relaitonships */
/* I do not have entities that belong to several microservices. */
microesrvice A, B, C with firstMicroservice
microesrvice D, E with secondMicroservice
microesrvice F, G with thirdMicroservice
paginate A, B, C with pagination
paginate D, E with pagination
paginate F, G with infinite-scroll
service A, B, C, D, E, F, G with serviceClass
search A, B, C, D, E, F, G with elasticsearch
References:
And as I said in the title, the code generated is reactive, quite bizare, only the code in the gateway is reactive. Microservices are not reactive.
And one more question, should I have generated code in the gate for communication with the microservices? At the moment I only have a code for communicating with its own database (Jhipster users database).
And if I have to write the code, the connection should be WebClient or something else? As far as I know, RestTemplate can not be use since is blocking and the gate is reactive so non-blocking context.
Jhipster version:
jhipster --version
INFO! Using bundled JHipster
7.7.0