Demonstrates microservices serving Splicer-generated data entities (models). Run this in conjuction with the SplicerClient-Droid project available here: https://github.com/SplicerPublic/SplicerClient-Droid/). There is a related blog post here: http://blog.splicer.io/grapically-compose-spring-boot-microservices-demo.
To run, open 3 command-line windows.
- In eureka-service folder type $./mvnw spring-boot:run.
- In splicer-user-service project, type $./mvn spring-boot:run.
- And in splicer-address-service project, type $./mvn spring-boot:run.
Eureka is available on port 8761; if working properly, the 2 microservices will be listed in the "Instances currently registered with Eureka" section. The microsservices are available on ports 8080, 8082. splicer-user-service demonstrates delivering User objects with nested Addresses. The splicer-address-service demonstrates delivering just simple Address objects. As a particular microservice starts, you will see in the log where test data gets stored and fetched in H2 database via JPA. Optionally you can import the projects as maven projects into your IDE.
The interesting thing here is that the models themselves were completely defined using the CAM editor. The model definition is contained in the template available here: https://github.com/SplicerPublic/Model-Samples/tree/master/demo. This means we can use a GUI to not only modify entity relationships, but also provide model normalization across microservices and (mobile) clients.
If you change the model in the CAM editor, upload your CAM template at the bottom of our homepage: http://splicer.io. Our server will process your template and return client-server model artifacts in a SplicerModel.zip that contains two more zip files. To install the server-side model, unzip JpaDataModel.zip to splicer-xxx-serivce/src/main/java such that you replace the "models" package.
To install the droid model, unzip DroidDataModel.zip to [MY_WORKSPACE]/SplicerClient-Droid/src such that you replace the "models" package. To run the client, follow the readme in that project. Detailed instructions for custom models are here: http://blog.splicer.io/mobile-app-sdk-and-form-generator-for-relational-data/.
The model component that we prefer to modify via source code is our repositories. The original project at https://spring.io/guides/gs/accessing-data-jpa/ shows how to use Spring repositories to write custom sql queries. See the findByLastName(...) method on that website's sample Repository class. This repository mechanism is key as it is complements the model definitions we create in the CAM GUI to essentially "filter" data -- joins, order by, etc.
Next, I plan to make both microservices share the same model artifacts (entity classes). Currently these are duplicated and identical in both microservice projects.