Starting with Microprofile & Vaadin & JNoSQL

Hello, y’all.

Let’s see how to develop a super-hipster Java Web App. This will be a long-running post, evolving as time goes, using technologies that are solving problems I’ll face. Please follow along and ask questions as they come!

We’ll start with a monolith from 2015: access to a NoSQL database, business logic and a web UI in a single deploy/release/file.

As you can guess from the title, I’ll already sprinkle some hipsterness to this Web app microlith. I’ll use:

  • For NoSQL Access, JNoSQL
  • For the business logic, CDI (coming from Wildly Swarm) 1.2
  • For the UI layer, Vaadin 8 (because I love not having to learn HTML/CSS/JSF to develop good functional Web UIs)

Life’s better with a scenario, so let’s pretend we’re developing a database of programming languages and will store their name, main link and allow visitors to comment about the languages.

So let’s code!

The initial commit contains the basic CDI + Vaadin dependencies from the Vaadin examples. Starting simple, we’ll now create the entities and create the database object (for now, in memory only).

We need a way to interact with the database, so I created a simple Web UI to add new data. Currently it only adds Languages; we’ll deal with comments later.

So, now we have CDI + Vaadin working. You can run this project with mvn clean wildfly-swarm:run and package it into a überjar with mvn clean package.

At this point, NoSQL is still missing in our app. I don’t want to create the NoSQL access with a proprietary API because I know that my initial choice of NoSQL database may not be the best for my use case. There are so many databases (more than 255) that I (still) don’t know where to start. So, I’ll use JNoSQL to model and connect my app to a NoSQL database. For now, I’ll use MongoDB as database just because, no real reason.

To start a new MongoDB instance using Docker, just run docker run -d –name mongodb-instance -p 27017:27017 mongo

Some changes are necessary to our model, to our DAO and to our UI to support using the Database, but the result is neat!

That’s it for now: started with CDI + Vaadin, added JNoSQL support. There are still many ways to go so this is super-hipster:

  • Break UI and Backend into Microservices talking over
    • REST
    • Kafka
    • gRPC?
  • Do away with DAO and use a Repository instead
  • Handle comments!
  • Add events to notify concurrent users of new languages
  • Launch Wildfly Swarm inside/as a Docker instance
  • … And many more!

What would you like to see next? Let me know!

Regards,

Leo.

Advertisements

One thought on “Starting with Microprofile & Vaadin & JNoSQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s