Skip to content

Development

Gradle Multi-Project Builds for Maven Users

This blog is the opportunity to check on new technologies:

I wanted to try another build solution for my Java backends. I used Maven for several years, both on OctoPerf and in my previous work experiences. Moving from Maven to Gradle is not necessarily easy, as the concepts involved are different.

This blog post is a guide for every developer with a Maven background that would like to give a try to Gradle (version 5.x), especially for authoring multi-module/multi-project builds.

It lists the differences between the two build solutions, step by step. You will learn what pitfalls to avoid, and how to setup code quality tools.

This is not a beginner guide on Gradle, it aims at describing the build setup of a complex project. However, be warned that my experience with Gradle is limited to this single project.

Spring Annotations Demystified

If you're here, it's probably because you have never really understood the differences between those Spring annotations:

  • What is the Spring @Service annotation for?
  • What's the key difference between a class annotated with @Component and @Service?
  • How can I use @PostConstruct and @PreDestroy?

The bad news is Your search is over! It's finally time to get a better understanding of when and how to use those annotations.

The section above describe each annotation and the best way to use them to fully leverage the power of Spring Framework.

All those annotations are designed to:

  • annotate classes,
  • enable instantiation and autowiring of those annotated classes.

But, how do they differ from each other? Let's dive into Spring's internals to find out!

Spring Boot + Hazelcast Tutorial

It all started when we had the following problem: How can you enable High Availability in a Rest API based on Spring Boot?

As you may know, we have two products: (both based on Spring Boot)

  • OctoPerf Saas-Edition: the online saas platform,
  • OctoPerf Enterprise-Edition: the full on-premise installable version.

While Saas-Edition absolutely needs High Availability, the Enterprise-Edition doesn't share the same requirements. But, as astonishing as it may seem, both versions share exactly the same code, while working slightly differently.

That's how I've come up with an elegant solution I'd like to share with you. This article aims to give an answer to multiple problems arising when clustering a web application (and especially Rest APIs):

  • Get an understanding of why clustering is inherently difficult (but not insurmountable),
  • How to hide clustering problematics behind a service that handles the difficult work for us,
  • How to enable clustering in a Spring Boot Rest API? Which framework should I use? (obviously we're talking about Hazelcast here)
  • How to make your Spring Boot App configurable to support High Availability without changing a single line of code, (using @ConditionalOnProperty)
  • How to implement a very simple Leader Election mechanism using Hazelcast and know when your instance is the leader.

The whole article is based on real-world code examples available on Github. Don't expect any long explanations on Distributed Systems theories.