Distributed lock on GCP Datastore

So, I needed a distributed lock on the GCP Datastore. In theory, it is all very simple: Get the lock Do what you need to do Release the lock And, when I started thinking about it, it became clear that I need to have some kind of transaction mechanism in order to obtain the lock….

Spring Integration Testing – WireMock and MQ

When writing integration tests for parts of the application that talk to other applications, for example calling REST APIs or sending JMS messages, sometimes we just want to test the application and not do end to end test. In this case, we would need to mock these other applications or their behavior. Mocking REST For…

Multiple projects inside one IntelliJ instance

When you are working with multiple projects, for example a number of microservices, it becomes problematic to have an IntelliJ instance open for each of those. There is a trick that allows us to have multiple projects open inside one IntelliJ instance (this saves time, space and RAM :)). Basics steps are as follows: Create…

MapStruct

When working with Spring services and exposing REST API calls, you would usually want to have a set of customized objects exposed to the outside world. These objects, usually called DTOs, can expose some of the domain objects or some projection made out of domain objects (or something else). For mapping between domain data objects…

Spring external .properties file

Before we proceed, be sure the check out the spring-cloud-config. Depending on your use case, this might be what you want , Spring Cloud Config. Lets say that we have following .properties files in our project: application.properties application-dev.properties application-prod.properties custom.properties Spring will use these files, if we do not tell it otherwise. We can override…

Remote debugging Spring Boot App

I have an application running on a remote server and I need to debug it. Don’t worry, server is firewall-ed and access is strictly controlled. What we want to achieve is to run the spring boot application in debug mode. We need to tell the VM to run in debug, how we will connect to…

Run SpringBoot application in Docker image

This is a short recipe on how to run your spring boot application within a docker image. The idea comes from John Thompson’s docker for java developer course, so be sure to check it out here https://www.udemy.com/docker-for-java-developers/. What do we want to accomplish? Create a fat (uber) jar of our application Create a Docker file…