Archive: April 2021

Spicy Spring: Splitting Configuration and make Properties immutable

Posted on by  
Willem Cheizoo

A Spring Boot application typically consists of several components handling the business functionality and probably some configuration to configure all these components. This configuration consists of defining some properties, setting up some beans with the right conditions and dependencies and wrapping it all together into a class structure. Nevertheless, the configuration of our Spring Boot application is also code. Let’s threat is as code.

In this blog we will se how we can improve our Spring Boot Configuration by splitting up the configuration from the properties and how this effects the design principles.

Continue reading →

Java Joy: Getting Multiple Results From One Stream With Teeing Collector

Posted on by  
Hubert Klein Ikkink

If we want to get two types of information from a Stream of objects we can consume the Stream twice and collect the results. But that is not very efficient, especially when the stream has a lot of objects. Since Java 12 we can use the teeing method of the java.util.stream.Collectors class to get multiple results while consuming the stream of objects only once. The teeing method takes two collectors as argument each returning a separate result for the stream items. As third argument we must pass a function that will merge the results of the two collectors into a new object.

Continue reading →

Follow through GitLab deployments with Slack

Posted on by  
Tim te Beek

Our team has a (not so) slight tendency to not immediately follow through with our deployments to production. We’ll create and review our changes, merge and deploy to staging, and dilligently test the changes there. And then…​ nothing happens.

It could be that something else needs our immediate attention, or someone else wants to confirm an issue is fixed; Or we might want to deploy at a different point in time as to not disrupt an ongoing process by a service restart. Any which way the result is the same: changes accumulate in staging, and with that the risk involved with the next production deployment.

To nudge ourselves to deploy to production more often we created a Slack App that gives us a daily report of such pending deployments. In this post I’ll showcase the code we use, and how to set up something similar yourself.

Continue reading →

Clojure Goodness: Create New Instance Of Java Class

Posted on by  
Hubert Klein Ikkink

Working with Java classes from Clojure code is easy. If we want to invoke methods or access fields on instances of Java classes we must first create an instance by invoking the constructor. In Clojure we can do that using the special form new or using a dot (.) notation. The new special form has the class name of the Java class we want to create an instance of as argument followed by arguments for the Java class constructor. With the dot notation we place a . after the class name followed by arguments for the class constructor to create a new instance.

Continue reading →

Weeding your micro service landscape

Posted on by  
Tim te Beek

When you look at how a given organization develops software over time, it’s not uncommon to spot evolutionary patterns that mimic what we see in nature. Particularly where micro services are involved, you might well be able to deduce which services came first, and which were developed later in time, by looking at various subtle variations in project structure, tools, dependencies, build pipelines and deployment descriptors. Later services copy elements from the initial template services, apply variations to fit their needs, and successful variations are again used in future services, or even applied in the original template services.

Variations from service to service are essential to maintaining a vibrant engineering culture, with room for experimentation within appropriate boundaries. Over time however, all the subtle variations can make it harder to reason across services, particularly when you want to apply broader changes.

In this blogpost I’ll outline, and provide various samples of, how I harmonize such diverse micro service landscapes, and the scripts I use to reduce the accidental complexity in maintaining the various variations.

Continue reading →

Gradle Goodness: Create Properties File With WriteProperties Task

Posted on by  
Hubert Klein Ikkink

If we need to create a Java properties file in our build we could create a custom task and use the Properties class to store a file with properties. Instead of writing our custom task we can use the task WriteProperties that is already part of Gradle. Using this task Gradle will not add a timestamp in the comment to the properties file. Also the properties are sorted by name, so we know the properties are always in the same order in the output file. Finally, a fixed line separator is used, which is \n by default, but can be set via the task property lineSeparator.

Continue reading →

shadow-left