I have a book on my shelf titled Service-Oriented Architecture by Thomas Erl. This is the fifth printing of the book; printed in June 2006. I’ve probably had it close to that long.
I purchased the book because I have been interested in the Web Service architecture for a very long time. At the time, and ever since, it reminds me of the early architecture applied to Unix applications. Small units of code that solved a single problem and could be chained together to address more significant problems.
Except, in the case of Web Services, it wasn’t that simple.
We entered a world of WSDLs and
From some of my previous posts, you can get the idea that I promote the idea of developing maintainable code rapidly. So I was pretty excited when I learned that the same group that was responsible for Grails was working on a similar project for Web Services. Hello, Micronaut.
In this post, I provide an introduction to the Micronaut framework and its features to provide a foundation for you to try it out yourself.
Micronaut is a microservices framework that does so much more than just Web Services (be still my geeky little heart).
With the rise of Web Services and Containerized applications, a useful framework can be just what you need in your toolbox. Micronaut promises fast startup times, a reduced memory footprint, minimal use of reflection, minimal use of proxies, and
The fast startup partially comes from the fact that, whenever it is able, it processes the annotations at compile time as opposed to run-time. I am hoping this also gives us errors caused by how we’ve configured annotations faster, at compile time instead of run-time.
To give you an idea, here is a quick introduction to working with the Micronaut command line interface. After installing the framework, you can create a Java Web Service with the command:
mn create-app <project-name>
This will create a Web Service application in Java. Using the
-l flag, you can change the language to Groovy or Kotlin. I’m fond of the Groovy language but have never used Kotlin.
mn create-app <project-name> -l=groovy
Setting the language to Groovy also changes the unit test that
For me, one of the exciting parts of the Groovy selection is the ability to use GORM. GORM is an Object-Relational Mapper used by Grails. It has always been one of the parts of Grails I’ve enjoyed. I was able to get the GORM objects I created for a Grails projects copied over to a Micronaut application with minimal changes. This allowed me to get a service set up in front of an existing database in a matter of minutes.
Once an application is created,
mn create-bean <object-name>
This will create a class that is a Singleton that can be injected into other classes.
mn create-job <object-name>
This will create a class that is annotated with Scheduled, and allow it to be scheduled for repeatable tasks.
mn create-client <object-name>
This command generates a simple client interface to a Micronaut service.
mn create-controller <object-name>
Use this command to create a
This creates the executable portion of the code, for instance, the endpoint. It also creates a test class for the Controller. As a proponent of doing unit testing early, I find this to be extremely helpful.
Since the makers of Micronaut have provided excellent documentation and tutorials, I have tried to introduce you to the framework in hopes to get you interested enough to try it out. Keyhole Software would be happy to help you implement Web Services of many types, including Micronaut.
This post scratches the surface of what Micronaut can do. I’ll be spending the next few weeks and months digging into the framework and hopefully bring you more insights into what you can accomplish with it. Thanks to OCI for developing a great tool.
Believe in Good Code.