In this blog post I will describe an example application that is based on the ideas given in the blog post Business value driven architecture with microservices. You can see that it is technical but it also includes some simple ideas that make software engineering a lot easier and a lot more usable for the end user.
Example application business processes
Our example application should support two business processes in a regular IT consultancy
- Track time
- Generate report for times
The report should later be used in our invoice application to create an invoice.
That are our requirements. They are a little bit rough and I would always recommend to spend a lot of time in requirements engineering. We are offering an own course on pragmatic requirements engineering.
We have to offer an user interface for multiple people that might be changing. Further it might be required that also people outside the company (subcontractors) will track time in this application.
- We will offer a web application
The web application will be used in a business context and should communicate with a server component. The server component is required because different people have to collaborate and work on the same data.
- We will use OpenUI5 as our front end technology
OpenUI5 is a mature and very well supported enterprise framework. It offers awesome integration with the service side protocol OData that makes selecting, filtering, paging and expand business related data easy.
We have to save relational data like persons, time entry, project, etc.
- We will use a relational database e.g. PostgreSQL
In our case the data is not that complex some strings, some dates, some numbers further we are only storing some megabytes of them. Relational database have to be proven to be very reliable in this case. Other format like JSON e.g. using MongoDB have issues with ACID transactions. Further data serializing like a date is not consistent across JSON serializers. OData 2.0 has specified how to serialize a date.
We have to save the relational data on the server.
This pair of technologies gives us a well tested and reliable server technology that can directly translate the client requests that are typically formulated in JSON into database structures. Further we can produce e.g. excel documents that are modifyable and processable by the user
Deployment and artifacts
Our deployment will be two plain old web applications bundled as war archives. We should do this in maven. The picture above shows how to do this in a very automized way using a lot of tools.
Our project will produce two maven artifacts therefore there are two pom.xml files. We also create a third one on the parent directory to be able to build the frontend and the backend with one maven command. This technique is called maven modules.
Maven will download all dependencies for us automatically. Compared with other package managers maven central will never delete a package. The mvn install command will create two war files in the target folders of the project. A simple archtype to initialize such a project was create by Adam Bien. After building the projects which can including unit tests as well we can deploy the files. So if you did a good job in writing your pom files and installed a wildfly properly. You can build and deploy your application with the following two commands:
mvn -f backend/pom.xml -Ddeploy.force=true -Dwildfly.hostname=example.com -Dwildfly.username=john -Dwildfly.password=johns-password wildfly:deploy-only
mvn -f frontend/pom.xml -Ddeploy.force=true -Dwildfly.hostname=example.com -Dwildfly.username=john -Dwildfly.password=johns-password wildfly:deploy-only
The frontend is an OpenUI5 application. A full example can be seen in the this repository. For the communication with the invoicing service the backend can produce an excel file and this excel file can be uploaded into another microservice. This other microservice is not sketched here.
OpenUI5 bundles the whole functionality in a so called component. One component should only support a small amount of business processes and be isolated deployable. If it is necessary to jump from one business process to another it can be done via normal links.
We will rely on JWT and OpenID Connect. That makes it possible for us to delegate the whole user management like registration, forgotten password, login and account management to other system e.g. Keycloak or Forgerock OpenAM
What about Docker or other container technologies?
So the question is what problem does docker solve? My personal answer is, that it makes it possible for the development department to deliver pre configured technical components like application servers or databases to the operations department. This is especially necessary if you have a big zoo of technologies and your technical components are changing often.
In our case PostgreSQL is released around once a year and wildfly too. For this technologies docker is a lof of overhead. Nevertheless if you are into docker. We recommend the new Java EE 8 archetype by Adam Bien.