Niels.nu


Niels Dommerholt's Weblog

Custom Converters with Spring Boot

Three ways to output JSONL

In this piece of example code I’m going to demonstrate a number of options that Spring gives you to implement your own custom media types. The Application returns a list of Quotes in JSON Lines format it gets from the Quotable API. An example repository is provided. more...


File Uploads and Downloads with Spring Boot

Without running out of memory

While most of my work has been on services that expose REST API’s or do Async communication via Kafka, there’s also quite commonly a need to let users upload or download binary files. In this blog post I’m going to explain how this can be implemented in Spring in a way that can scale to very large files. The primary goal is to stream directly from/to disk instead of keeping the data in memory. more...


Nice Random Numbers

Are they a good ID?

Ever wondered why sites like YouTube, Reddit or ImgUr use these 'weird' IDs that seem to be made up of a number of random letters and numbers? Well, they pretty much are! In this blog post we’re going to dive a bit into how they work, what the reasoning is behind them, and why you often don’t want to just use a database that creates incremental IDs. more...


A Kotlin Retrospective

Kompetitive Advantage

After two years of being in the awesome position of being able to use a 'new' language in my day to day work, I felt it was a good moment to look back at this time and consider what I learned from it, and how I feel about using Kotlin now. more...


The Road to Independence

Jumping In At the Deep End

Some of you might have noticed there is a pretty huge gap on my blog. It has been more than a year since I last published a post. So what happened in the meantime? Well I quit my job, that’s what happened! 2019 was the beginning of a big next step in my career: I went independent. In this blog post I’m going to look back on the process, the benefits and downsides of independent contracting, and my next steps. Warning: this is not a technical blog-post, it’s more a 'dear diary' type entry! more...


Spring and DynamoDB Integration Testing

TestContainers to the Rescue!

Deploying cloud native Spring applications on cloud providers allows you to leverage great managed tools such as databases, object storage systems and queues. In my current project many of our microservices, which are deployed on Amazon ECS, use DynamoDB for storage. This is great of course, but how do you integration test these services? In this post I’ll show you how you can use TestContainers to do integration tests in a Spring microservice backed by DynamoDB. more...


Software Architecture in an Agile World

Dealing with Complexity

"We’re agile! Just build it!" Or on the other hand; "agile does not support Software Architecture so we should stop doing agile". Two very different opinions that you can sometimes hear within the same company. Which one is right? Or are they both wrong? Should we stop doing architecture to be more agile? Why do we even need architecture? In this post I’ll give my view on the matter and hope to inspire you to combine Agile and Architecture in your organisation. more...


Testing the Architecture

ArchUnit in Practice

While many of the architectural challenges we have to deal with are big hard choices, there are also many smaller simpler ones. From "don’t call repository classes from controllers" to "don’t have cyclic dependencies". In most projects I’ve worked in these are unwritten rules. But why not write them down in a way that we can also see if the rules get broken? Can we test these rules? more...


Lightweight Architecture Decision Records

With tools to do the heavy lifting

As a software engineer you make architectural decisions all the time. Neal Ford calls these software engineers 'accidental architects'. I personally prefer the term implicit architects because I don’t think software engineers doing architecture is in any way an accident or even something you would not want. You’re the expert after all. Decision making is one thing though, how do you document these decisions? more...


My Move to Kotlin

A new love

Back in '98 when I started with my CS education Java was the first programming language we were taught. Before I had experimented with QBasic, C and assembly but that was the moment where I started to really grow into being a software engineer. While I made something excursions to other languages; PHP, C#, JavaScript and even ColdFusion, Java always was my 'base' where I returned to. My great love as it were. But now she’s fallen out of fashion and I’m moving on to greener pastures: Kotlin. more...


Serverless Java with AWS Lambda: Introduction

Where's my box?

Just as we are over the crest of the microservice hype and can finally see how this architectural tool might (or might not) solve our problems the next hype is already here: serverless programming! In this first blog post I’m going to explain what serverless is, what it isn’t, and how it can change the way we create software. In the next posts I’m going to show a few simple examples using a well known 'serverless' platform: AWS Lambda. more...


Aspect Oriented Programming with Spring Boot

Aspects? Pointcuts? Join point? Huh?

While much of the terminology sounds rather complex Spring Boot has an excellent AOP starter that makes actually using AOP a breeze. In this blog post I’m going to (hopefully) make you as enthusiastic about Spring AOP as I am. As usual this blog post comes with a repository with runnable code. more...


Spring Cassandra Integration Testing

With Achilles JUnit and Test Containers

In the project I’m currently working on we use Spring Boot based microservices backed by Cassandra for storage. Through the last year of this project we’ve been through a few iterations of how we handled the interfacing with Cassandra. This also had substantial impact on how we handled integration testing. In this post I’m going to show you our current approach (with Achilles JUnit) as well as a more generic approach with Test Containers. more...


A Docker Swarm Bramble on a ClusterHat

Easy as Raspberry-pie!

Pretty isn’t it? Last week my birthday present arrived: a Raspberry Pi 3 with two Raspberry Pi Zero’s (1.3) and a ClusterHat. The Pi 3, ClusterHat and one Zero I got from the Pimoroni shop while the second Zero was supplied by The Pi Hut: both shops only allow one Zero per customer due to the huge demand. Fortunately one of my colleagues volunteered to also order two Zero’s for me, bringing the total to four! more...


Enabling HTTPS termination in Traefik

Let's Encrypt my Blog!

In a previous blog post I showed you how I set up a fully dockerized environment for my VPS hosting my blog. I also mentioned that I wanted to enable HTTPS for my blog. In this short blog post I’ll show you how to enable automatic Let’s Encrypt certificate retrieval in Traefik. more...


Spring Boot, Docker and Traefik

How to deploy a dockerized Spring Boot app behind the Traefik reverse proxy

In a previous blog post I showed you how I set up a fully dockerized environment for my VPS hosting my blog. Now I will show you the biggest benefit of this set up: fully automated Spring Boot deployments. more...


Continuous Blog Delivery Part 2

Build automation with Jenkins and Bitbucket pipelines

In my previous post I showed how I dockerized my blog and had it served via the Traefik reverse proxy. In this episode I am going to show you how I automated the build of this blog in Jenkins and trigger these builds using Bitbucket pipelines. Also make sure you check out the next episode that shows you how to deploy a Spring Boot application and the final episode where I show how I enabled HTTPS. more...


Continuous Blog Delivery Part 1

There's no such thing as over-engineering.

This blog was started two years ago and during that time it has been running on the exact same configuration: Nginx serving the static content running directly on a TransIP VPS. While the updating of the blog itself is really straight-forward (SSH into the machine and run an update script) it is now 2017 and having to do anything manually is of course completely unacceptable! In this series I am going to document process of setting up a true CD workflow for my blog using Docker, Traefik and Jenkins. more...


Spring Boot Microservice Versioning

Backward compatible REST responses using @ControllerAdvice

Almost a year ago I wrote a blog post about MicroService versioning where I explained a few common problems with MicroServices and a few different approaches on how to solve versioning. My favorite solution to the versioning problem is to have the service 'downgrade' responses to older versions of that response based on a client supplied 'protocol version'. In this blog post I will walk you through an implementation of this adapter pattern using Spring’s @ControllerAdvice. more...


Spring Boot Websocket STOMP Example

How to create a Spring/Stomp server with a Java client

In our current project we want to add a service that uses websockets to push messages to our mobile applications. While the documentation on Spring Websockets + STOMP is excellent when it comes to implementing a service that is consumed by a simple web application, the example on how to use the STOMP client doesn’t really align very well with the short getting started guide. Since I hit a few snags in the implementation I’m creating this example so you don’t have to. more...


RSA Signing and Encryption in Java

How to create a RSA keypair and use it to sign, verify and encrypt information in Java

When it comes to encryption and signing RSA is the de facto standard for public key cryptography. Invented in 1977 RSA (named after it’s inventors, Ron Rivest, Adi Shamir, and Leonard Adleman) and it’s successors are still used in many if not most of the systems you use today. It is in fact one of the core components of what keeps your passwords safe when logging in; HTTPS. In this post I will show you how to use RSA in Java. more...