Coda Hale, Dropwizard and Scala
Coda Hale, Dropwizard and Scala
Join the DZone community and get the full member experience.Join For Free
Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!
I enjoyed working with Scala at my last client. One of the frameworks that we used there wasCoda Hale‘s Dropwizard framework. The Dropwizard project, itself, is written against Java, and provided a nice bunch of friendly open source frameworks and applications already integrated together in read-to-run server. The developer just writes configuration, resources and if necessary templates to plugin in the application framework. The great idea is that you can dropped in some code into the setup and you are generally on track with a monitoring, logging and healthy beating infrastructure.
- Jetty for a lightweight Java EE 6 style Web Servlet container
- Jersey JAX-RS for REST
- Jackson for JSON serialization
- The incredible Metrics library for handling all sorts of Developer/Operation metrics
- Logback and SLF4J for performance logging including integration to UNIX style SysLogs through a network port
- Hibernate Validator 1.0 for bean validation
- Database help with JDBI and Liquibase
- Guava is useful for writing functional programming Java before Lambdas (Java SE 8)
Coda Hale presented an interesting talk on the importance of measuring critical systems in an disparate and diverse architecture. He posited the idea that you need to know the numbers in order to make key decisions of your system. His talk is available on YouTube You Tube Metric, Metrics are Everywhere (opens separate window) and the slides are here.
I did say that Scala is being used in this blog entry. Dropwizard has a Scala module, which I saw definitely being used in the Registered Traveller project at GOV.UK. It made sense to really on pre-existing open source framework (NIH, DRY) based on sound ideas like health checks, pings and pongs and logging. You can build reasonable scalable, maintainable and robust Micro Services in Java and Scala with this integration of configuration and resources.
The issues with Dropwizard are that some of the modules are dated. In particular, the Jersey framework integrated is only 1.18, where as a recent check of MvnRepository.com already shows the latest Jersey version 2.13 or better. The latest version of Jersey provides Java EE 7 style API with the standardised JAX RS 2.0 API and the Client side API. If you want to use Java EE 7 then DropWizard is not yet capable of running against Jetty 9.
I mentioned that there is a Scala module for Dropwizard, which is a fork on the original unmaintained project. Brett Hoerner maintains this Github project. The module does work with Scala 2.11 even though the original fork dates back to Scala 2.9. There are some clunky expositions of Guava and Java that seep through to the Scala side. Ok the Java framework is not written in Scala, but Drop Wizard solves a pressing issue with bundling working application/infrastructure that almost ready to go for the enterprise. There could be more Scala style library API, but most of all it would great of the Java framework was upgraded to latest Java EE 7 features and frameworks.
I believe that sometimes people forget that Scala is hybrid of object-oriented programming and functional programming. That is exactly what the inventor of Scala wanted to achieve on the JVM. Therefore there will be people will prefer a one of these directions and just because that someone choses one these orthogonal does equate with ineptness or inferiority. To penalise somebody because, to date, they have had less experience of FP and more experience OOP or the other way around, in my mind at least, demonstrates elitism, contriteness and damn right stupidity. It more important to continuously improve on both axes as much as possible and we all have something to learn from each other.
Published at DZone with permission of Peter Pilgrim , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.