Spring native is the way to compile Spring applications to native images with GraalVM without changing anything (or at least some stuff) in our code. How to use it? Isn’t the topic of this post, just follow this awesome getting started.

In a company, every choice we do as software developers should be guided from a simple sentence: solving problems saving money.

How we can do that? Optimizing resources used by our software.

In this post, we will analyze some results we got from a 3 service migration that I did during an internal company hackathon and how using native…


Waiting for a more complete article about my (short) experience with Spring Native, I’m proud to share a configuration used to configure an application that uses Elasticsearch, Apache Camel, and Apache ActiveMQ.

I got help reading (and copying :D) some code in the Apache Camel extensions for Quarkus and in the ElasticsearchRepositoriesHint provided by Spring doesn’t work for me because I’m using Elasticsearch without Spring Data.

Before finish I have to say thanks to my friend Roberto to help me with that migration.

And now, as Linus Torvald said: talk is cheap, show me the code!


Hello everyone! Some days ago I had to build a list of objects and I would like to use the Builder pattern.

You don’t bother about Java? Skip to Kotlin!

In this example, I will image that I will build an automobile manufacturers list, so I will have a classic Manufacturer builder that I can use like:

Manufacturer manufacturer = new ManufacturerBuilder()
.withName("Fiat Automobiles S.p.A")
.withNationality("Italian")
.withContinent("Europe")
.withFoundationYear(1899)
.build();

I have a builder and obviously my Manufacturer object is immutable!

I need a list of manufacturers and I wouldn’t write verbose code like:

List<Manufacturer> euroManufacturers = new LinkedList<>();manufacturers.add(new ManufacturerBuilder()…


In this post I will do a simple refactoring of a real small piece of code that I found in a legacy code base and after I will translate the example to Java to Kotlin. Why? Only in order to demonstrate why Kotlin can be useful for writing more maintainable code and not only a fashionable language for old Java developer, like me :)

Every day we face simple problems like splitting a list into two new lists.

public void myMethod(A source, B destination) {
List<Credentials> list = source.getCredentials();
Set<String> users = new HashSet<>();
Set<String> groups = new HashSet<>();


Photo by Jeff Prieb from FreeImages

Studying about Kotlin Coroutine, I often read Structure concurrency but what it really means? Structured how many times do you hear this word about programming? Structured programming, is a programming paradigm born to improve code quality and clarity, by using structured control flow constructs of selection (if…then…elen) and repetition (while and for), block structures and subroutines. This concept born by some considerations made by Edsger W. Dijkstra in “Go To Statement Considered Harmful”.

Basically we have to stop to write:

10 i = 0
20 i = i + 10
30 PRINT "i: " + i
40 IF (i < 100) GOTO 20…


With back-pressure, your tasks become polite and they wait for their turn.

Do you want more information about Kotlin Flow? Read this first!

This is one of the best features of reactive programming and it is borrowed from fluid dynamics. Wikipedia defines it as:

Resistance or force opposing the desired flow of fluid through pipes

So, in our domain, it means to control the data flow to be sure that the load doesn’t kill our application. Traditionally reactive programming libraries have some dedicate feature but with Flows the back-pressure management is achieved using Kotlin suspending functions. …


Nowadays we are listening to words Reactive programming every day, and many projects, like Spring, are adding reactive support to their libraries.

If you are a Java or Kotlin programmer you usually hear frameworks like RxJava, Reactive Streams, and Reactor, but with Kotlin there is a new alternative provided by the language: Flows!

Flows are basically asynchronous streams that relay on coroutines for their execution. When we are talking about asynchronous streams we can have:

  • hot stream: the stream is always active and the subscription to the flow starts from the point where is the emission of data on the…


Locking, often, isn’t a good idea, and trying to lock something in a distributed environment may be more dangerous. But sometimes, we need to keep this risk and try to use a distributed lock for two main reasons:

  • Efficiency: a lock can save our software from performing unuseful work more times than it is really needed, like triggering a timer twice.
  • Correctness: a lock can prevent the concurrent processes of the same data, avoiding data corruption, data loss, inconsistency and so on.

We have two kinds of locks:

  • Optimistic: instead of blocking something potentially dangerous happens, we continue anyway, in…


Clustering a microservice, or a web application, in a single datacenter can help us in performance and availability, but what’s happens when our users are distributed worldwide, or there is a disaster and our data center isn’t more available?

TL;DR: Jump directly to the Demo section!

So, we decide to serve our application from the closest datacenter to the user, to improve network latency, database load, and in general performance, and, moreover, we will use the other datacenter as a backup when the principal datacenter isn’t available, in order to have high availability (HA), also in case of a disaster…


When you start a WebFlux project you haven’t the support for static resources, like HTML, CSS and JS files, provided by Spring Boot project. Unfortunately how to solve this simple task isn’t so well documented, so I decided to write this post.

The simplest way I found is to define a resource router as you can see below:

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.io.ClassPathResource
import org.springframework.web.reactive.function.server.RouterFunctions.resources

@Configuration
class WebConfiguration {

@Bean
fun resRouter() = resources("/**", ClassPathResource("static/"))

}

Now you can run your application and navigate to:

http://localhost:8080/index.html

But if you try to remove the file name in the URL, you…

Davide Cerbo

Open-space invader, bug hunter and software writer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store