Niels.nu


Niels Dommerholt's Weblog

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...


Controller Advice - Exception Handlers

Clean and reusable error handling through Spring @ControllerAdvice

Spring is a framework that gives you great flexibility and extensibility. Sometimes the flexibility is even a bit overwhelming; there are often multiple roads leading to Rome. In this blog post I am going to show how we approach error handling in our Spring Boot based micro service project. more...


Devoxx Talk

I'm making a note here: Huge success!

This was awesome! Last monday I was lucky enough to be able to do a talk at Devoxx Belgium, the biggest Java conference in europe! My talk was based on my blog post on Sentiment Analysis with Apache Spark which was in turn based on the short Ignite Session I did at JFall 2015. While it wasn’t my first talk for a crowd it was by far the biggest crowd I did a serious talk for and it was a huge thrill! I can understand that this can become addicting! more...


Asynchronous REST results in Spring

Improve resource utilization through Asynchronous results

Most Spring Boot REST tutorials start with the basics, as they should. But when you start using Spring Boot in production you will soon find out that following the examples to the letter might cause you to run into performance problems. In this post I will show you how to make use of Spring’s built-in asynchronous capabilities. more...


Why there are so few women in tech

Education is a funnel

Too long, didn’t read: This is why: more...


Cassandra ResultSet Paging

Optimize response sizes through Cassandra's built in paging mechanism.

In mobile applications the amount of data sent from the REST service to the mobile application is an important consideration. So for any dataset where we might return a large number of rows we have to implement paging. In this post (based on the current documentation) I will show you how Cassandra handles paging and how you can implement paging in your stateless REST service. more...


Rate Limiting an API with Cassandra

TTL inserts for fun and profit

Often there are API’s in your system that are sensitive to the amount of requests they receive per second. In our system it’s the registration flow where users can request an SMS to be sent to their cell phone. For an interesting (and fun) read on why you want to rate limit such an API check out this wonderful article. In this post I’ll show you how I implemented such a rate limit on user’s phone numbers. more...


Cassandra 3 Data Modelling with Materialized Views

Using Materialized Views to lower ETL complexity

One of the largest challenges for developers starting with Cassandra is the paradigm shift when you move from a normalized relational data model to a typical Cassandra data model that is strongly denormalized. What helped for me is to forget about how SQL-like the Cassandra Query Language is and just see Cassandra as a Hash Map: you have to retrieve everything by key. This automatically leads to a lot of data duplication and thus a lot of additional code. Fortunately with version 3 Cassandra can help you with duplicating data mutations by allowing you to construct views on existing tables. more...


Micro services - Versioning strategies

Identifying the problems with versioning and exploring possible solutions.

μServices are hip! They have been for a while now. But while a very strong modular loosely coupled approach tends to make projects easier to maintain it also brings it’s own set of problems. In this blog post I want to dive into one of these problems; versioning. more...


StringBuilders - How smart is the compiler?

Or; fun with javap

Most experienced Java developers probably know that when you concatenate strings together in your Java code the Java compiler will use a StringBuilder for you. However; there are quite a few misconceptions about how smart the compiler actually is. In this post I would like to explain what it does, what it doesn’t do, and how to use the tools at your disposal to figure this out yourself. more...


Build your own Twitter AI using Markov Chains

But please don't let it become sentient!

In this post we’re going to explore Markov Chains and how to use them to create a twitter 'AI' that can create new tweets based on the behavior of other twitter users. more...


Kafka - Creating custom serializers

Create Kafka serializers for JSON, Kryo and Smile.

I am currently working on a pet project involving Spark and Kafka and I noticed that there are currently very few examples of how to create your own serializers for the new 0.9.0.0 API. In this blog post I will show how to create serializers for my own custom class that (de)serializes from/to 4 different formats: strings, json, smile and kryo. more...