Idempotent events with revision numbers In an event-based system (possibly according to DDD) you will be notified about changes. For example, if the price of a product has changed, a PriceUpdatedEvent will be thrown. Any system interested in price updates can listen and react to those events. In most cases the reaction triggered by an event should be idempotent. This […]
Concrete vs Generic – The story of a data model The story of a project In the last project I was working on, we struggled a lot with our data model. The task was to replace an old product service with a new one. The old system has grown over time, was hard to maintain and the guys who made it have been gone a […]
Event Sourcing with Kotlin Some weeks ago I published a demo project on GitHub showing a Domain Driven Design with Kotlin. You can find the original blog post right here. Now I took the approach one step further and added Event Sourcing to the demo. Here’s what I did. Event Sourcing The basic idea of Event Sourcing is to […]
Don’t depend on details – an example I recently read Clean Architecture by Robert C. Martin. The book gives a simple advice: don’t depend on details! For Uncle Bob details are things like the database or message broker. Your architecture shouldn’t depend on the actual used implementation of those details. Whether your are using Oracle, MySQL or DynamoDB, whether it’s ActiveMQ, Kinesis […]
find vs. get Three years ago I wrote a blog post with the provoking title “Don’t use Optionals for data repositories“. The post received a couple of critical comments and I had the feeling that I didn’t made my point clear. This week I stumbled over the same topic again, but from a slightly different point of view. […]
Object updater pattern in Kotlin Updating data is one of the most frequent use-cases in applications. But it might also be a painful task which results in a bunch of ugly code. I recently stumbled over a typical update scenario in a Domain-Driven-Design (DDD) application. In the following, I want to show an elegant solution implemented in Kotlin (a Java […]
Encapsulated modules and clean tests with Spring’s @Configuration Usually we use Spring’s @Configuration to define some special beans. A classic example is the definition of a data source: 1234567 @Beanpublic DataSource dataSource() { DataSource dataSource = new DataSource(); dataSource.setUsername(username); // ... and so on ... return dataSource;} However, we can also use Spring’s @Configuration to build better modules which helps us to writer cleaner tests. Let’s go through an example. An example Let’s assume we have an application which uses domain […]
Messages vs. Events vs. Commands In a distributed environment, services must communicate with each other. One of the most popular ways of communication is messaging. Tools like ActiveMQ, RabbitMQ or Kafka are making it easy to exchange messages between systems. But no matter which broker you are using, you must decide which kind of message you want to send. Messages […]
Effective error handling for ActiveMQ topics No matter what type of software you make, there will always be errors. There might be bugs in your code or an external system is just down at the moment. No matter what it is, it will cause you trouble. Asynchronous messaging (with JMS) might help to deal with such situations. Especially when you depend […]
Virtual Topics in ActiveMQ A couple of days ago I published a post about the difference between queues, topics and virtual topics. Today I want to share some practical information on how to use virtual topics in ActiveMQ with Spring Boot. Virtual Topics Virtual topics are a combination of topics and queues. Producers will write messages to a topic […]