DEV Community

Cover image for An example Jooby app, Jooby is one of the fastest and performant framework in Java
Azizul Haque Ananto
Azizul Haque Ananto

Posted on

An example Jooby app, Jooby is one of the fastest and performant framework in Java

TL;DR
Here is the repo - https://github.com/Ananto30/jooby-example-shortify

Jooby seems a very promising framework. It's easy and fast. I noticed the Techempower benchmark last week and found this amazing framework that supports Java and Kotlin.

History(!!) 🧐

I have been working with Webflux for around a year. Webflux is the implementation of reactive Java on top of Spring-boot framework. It is basically a non-blocking concept and reuses threads for concurrent connections, really good for modern services with lots of concurrent requests. But writing reactive code is not that fun, you have to maintain a chain and catching errors and no filtering and less readable code and so on... 😰 That's another talk.

So basically I was looking for another framework with the same performance but not reactive 😐 And I think Jooby is that one! 😃 And also it has the ability to run Event-loop, the non-blocking concept like Webflux where we can use the reactive java. Even the default mode supports both blocking and non-blocking in the same app! This is really cool!

Getting started

To begin with, it's really easy to setup a Jooby project, though it hasn't got starter like Spring-boot, but the jooby-cli is enough to bootstrap a new projects with varities of configurations. Easy way is to -

  1. Download the jooby-cli (please refer to the doc's download, the link may change)
  2. Add bin/jooby or bin/jooby.bat to the system path variable.
  3. Set workspace jooby set -w ~/Source
  4. Create a new project jooby> create myapp --gradle --mvc --docker This is how I created mine, you can find other options by jooby> help create.

You can find the details here - https://jooby.io/#getting-started.

Overview

I have created this app - https://github.com/Ananto30/jooby-example-shortify for exampling and maybe I will add more modules and functionalities to it for future tutorials. This is a url shortener app, uses redis to keep track of them. A very simple app, implemented in a spring like architecture.

I won't go deeper into every module or explaining all of my code. I will do that if you need me to, please comment for that. Mostly I will talk about the overall app structure.

I have used the mvc api of jooby. It's more like the spring-boot concept. My app has a controller, service, and some dto's. You can relate the architecture to spring-boot. All you need is to install the modules, there are a handful of modules already integrated to jooby and for other ones you just need to write an extension and register that in jooby's service registy, more like a bean in spring-boot, but with less magic, full control.

You can pass Context to any controller, handler, or service, just take it as an argument. There are filters, I have used them for request response logging, somewhat like the AOP. The error handler is really easy to integrate. And much more... I really loved the framework, it's easy with less magic!

Please check out my repository for a thorough idea of the app, and if you have any questions or idea or opinion or anything 😅 comment down below 👇

Top comments (1)

Collapse
 
ananto30 profile image
Azizul Haque Ananto

Nice! Please share your experience and what do you think about the Jooby framework overall?