Dynamic proxies in Java is a simple and very useful feature. Usually we create an interface implementation and then compilation is involved. With dynamic proxies we can implement a list of interfaces at runtime. A proxy object will be created, when a method is invoked on that proxy instance, the methods invoked will be forwarded to an invocation handler specified. ...
Read More »Home »
Java Concurrency: Threads and Runnables
Threads are everywhere, they are the basic building block of every server application out there. Usually in Java using threads is just a combination of Executors and Runnables however let’s have a closer look on a thread and how it works. Supposing I want to start a thread, it can be as simple as this. Thread thread = new Thread(() ...
Read More »Add ZipKin to your Spring application
If your application contains multiple services interacting with each other the need for distributed tracing is increasing. You have a call towards one application that also calls another application, in certain cases the application to be accessed next might be a different one. You need to trace the request end to end and identify what happened to the call.Zipkin is ...
Read More »Use Redis GeoHash with Spring boot
One very handy Data Structure when it comes to Redis is the GeoHash Data structure. Essentially it is a sorted set that generates a score based on the longitude and latitude. We will spin up a Redis database using Compose services: redis: image: redis ports: - 6379:6379 Can be run like this docker compose up You can find more on ...
Read More »Use JMH for your Java applications with Gradle
If you want to benchmark you code, the Java Microbenchmark Harness is the tool of choice.In our example we shall use the refill-rate-limiter project Since refill-rate-limiter uses Gradle we will use the following plugin for gradle plugins { ... id "me.champeau.gradle.jmh" version "0.5.3" ... } We shall place the Benchmark at the jmh/java/io/github/resilience4j/ratelimiter folder. Our Benchmark should look like this. ...
Read More »Gradle: Push to Maven Repository
If you are a developer sharing your artifacts is a common task, that needs to be in place from the start. In most teams and companies a Maven repository is already setup, this repository would be used mostly through CI/CD tasks enabling developers to distribute the generated artifacts. In order to make the example possible we shall spin up a ...
Read More »Debezium Server with PostgreSQL and Redis Stream
Debezium is a great tool for capturing the row level changes that happen on a Database and stream those changes to a broker of our choice. Since this functionality stays in the boundaries of a Database, it helps on keeping our applications simple. For example there in no need for an application to emit events on any database interactions. Debezium ...
Read More »Mock GRPC Services for Unit Testing
On our day to day work we develop applications that include interactions with software components through I/O. Can be a database, a broker or some form of blob storage. Take for example the Cloud Components you interact with: Azure Storage Queue, SQS, Pub/Sub. The communication with those components usually happens with an SDK. From the start testing will kick in, ...
Read More »Add Grpc to your Spring Application
On the previous example we had a Java application spinning up an http server and upon this Java process operating a GRPC application. If you use frameworks like Spring you might wonder how you can achieve a Grpc and Spring integration.There are libraries out there that do so, we shall use the grpc-spring-boot-starter from io.github.lognet.We shall start with the dependencies. ...
Read More »