Blog
Collection of curated blog posts from me.
Pulumi for Java Developer - Getting started with IaC
Introduction In today’s cloud-native world, managing infrastructure by hand is no longer practical. Infrastructure as Code (IaC) has emerged as the de facto standard for managing cloud resources. Terraform has dominated this space with its domain-specific language. Pulumi takes a different approach, which benefits Java Developers. What is Pulumi? Pulumi is a modern Infrastructure as Code platform. It lets developers use familiar programming languages instead of domain specific one like HCL or YAML.
November 21, 2024
Mastering Error Handling in Spring Boot with ProblemDetails
Image by author Introduction Hello everyone! In this article I will try to cover a game — changer for API error handling in Spring Boot — the ProblemDetails RFC. If you spent a long time wrestling with inconsistent error responses or scratching your head over how to structure your API’s error message, you’re in for a treat. What is the deal with ProblemDetails? Spring Boot + ProblemDetails First of all the ProblemDetails is not just another Spring Boot feature — it is an IETF standard (RFC 9457) that defines a “problem detail” as a way to carry machine-readable details error in a HTTP response.
September 26, 2024
Automate your business processes with Temporal.io and Java
Introduction Today the world is a fast-paced business environment, and automating processes is crucial for staying competitive. Temporal.io, a powerful open — source platform, simplifies the development, of scalable workflow automation. Temporal.io enables developers to create efficient, resilient business process automation not only with Java but with a wide — range of different programming languages. In this article, we will explore how to leverage Temporal.io and Java to streamline your operations.
September 24, 2024
Mastering JUnit 5 - Advanced Techniques for Efficient and Powerful testing
Meme about unit tests Hello everyone in this article we will dive into note-worthy JUnit 5 annotations which help you to write extensive unit tests. Before starting to start writing unit tests we have to add required dependencies to our pom.xml or build.gradle. pom.xml<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>me.vrnsky</groupId> <artifactId>mastering-junit</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>5.11.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.
September 24, 2024
Advanced Java Garbage Collection — G1 and ZGC
Garbage collector Hello everyone! In this article, we discuss advanced Java Garbage Collection: G1 and ZGC. Introduction Both garbage collectors are designed to optimize memory management in large-scale applications by improving the efficiency of memory allocation, deallocation, and garbage collection. Both G1 and ZGC are designed to reduce pauses while performing the garbage collection cycle and improve overall system performance. G1 or Garbage First G1 is a fully incremental garbage collector that divides memory into multiple regions.
August 15, 2024
Spring Boot & Infisical - Managing your sensitive configuration
Hello everyone! In this article, I’ll show you how to employ Infisical in your Spring Boot application. But last year, HashiCorp changed Terraform’s license to non-open source. This could also happen to Vault, or not. The second reason why I chose Infisical for this article is because IBM acquired Terraform this year. Introduction Like the HashiCorp Vault, Infisical is a secret management platform. Let’s start by starting up the Infisical instance locally with the docker-compose file provided by the documentation.
May 30, 2024
Spring Boot - How to build layered jar
In this article, I will show you how you can build a simple CRUD application and create a layered jar. The inventory service manages inventory, such as left stocks, i.e., some drinks, merch, or something else that can be stored in the warehouse. Reasons for choosing layered jar: If you have an extensive application with different dependencies If you need flexibility in layer updates Reasons for choosing Uber Jar: If you have a simple application with a relatively small number of dependencies If you need simplicity in the deployment process DockerfileFROM eclipse-temurin:17 as JAR_EXTRACT WORKDIR /app ARG JAR_FILE=*.
January 6, 2024
Spring Boot and gRPC - Boost your service communication
Introduction In this article, I will describe gRPC and how you can employ it in your project. The motivation creation of gRPC The motivation behind creating gRPC was that developers and businesses require faster and more efficient solutions. The existing technologies utilize HTTP 1/1.1. The Spring Boot supports Undertow, but Tomcat requires some additional changes. It is why creators employed HTTP 2 in gRPC. This article will create another CRUD service to manage restaurant reservations.
January 6, 2024
Spring Boot and JOOQ - Getting started
This article will show how to use jOOQ in your spring boot projects. Why do we need jOOQ? There is a lot of pain using JPA and Hibernate. That is why we have something jOOQ. First, we need to create a database schema. In this article, we will develop a simple CRUD (create, read, update, and delete) application to manage goods. The first step is to design our database. The application will contain only one table — goods.
January 3, 2024
JUnit 5 - How to write more test with less code
Introduction In this article, I will show and explain how you can write more tests with relatively small changes in your code. Recently, one of my colleagues wrote a massive test with repetitive code. The difference between test cases was only data that was submitted to the service. I will use JUnit 5 in this article, but feel free to check the library docs you use for writing tests. Problem Let’s imagine the following situation: we have a service that accepts the following data and returns the following response.
December 31, 2023
Spring Cloud Functions, Kafka - How to interact asynchronous
Introduction This article will show how to use the Spring Cloud Functions projects. The Spring Cloud Functions is the best approach to implementing a straightforward business logic. Nowadays, the usage of message brokers such as Kafka has increased. I will implement a simple system in this article, as shown below. Diagram of developing system Implementation I will start with a simple example of a cloud function, which is the same as a rest endpoint in the classical spring boot web application.
December 24, 2023
Spring Cloud Config, Spring Cloud Bus & Kafka - How to set up automatic updates of your configuration
Introduction In this article, I will show you how to achieve automatic updates with Spring Cloud Bus and Kafka The Spring Cloud Bus, according to documentation: Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then broadcast state changes (e.g., configuration changes) or other management instructions. AMQP and Kafka broker implementations are included in the project. Alternatively, any Spring Cloud Stream binder on the classpath will work out of the box as a transport.
December 21, 2023
Spring Boot Mutation testing with JUnit5, Testcontainers, and Pit
What is mutation testing? Mutation testing is a type of testing that validates new and existing tests. More formal definition from Wikipedia: Mutation testing (or mutation analysis or program mutation) is used to design new software tests and evaluate the quality of existing software tests. Why do we need mutation testing? The problem that solves mutation testing is checking the validity of the existing and new tests. I often have met invalid unit tests that have covered only the happy path and no other paths.
December 13, 2023
Digital Image Processing Basics
Introduction Digital image processing is the acquisition, analysis, and performing of a wide range of operations on an image. In digital image processing, there are three types of images: Binary Grayscale RGB The digital image can be represented within the two-dimensional array. A binary image is represented by a dimensional array where each cell stores 0 (black) and 1 (white) values. A grayscale image is a two-dimensional array where values in the array lay in a range from 0 to 255
November 26, 2023
Write your Spring Boot (3.x) starter with Kotlin & Maven
Some companies use Camunda(TM) BPMN Engine for managing the business automatization process. Most of the functionality provided out of the box is enough for most cases. But recently I have realized that we have always written our service to send messages to the engine. So, I decided to write my starter. The native language for Camunda is Java, but it supports many other languages. Since I want programming experience in Java, I have decided to write my starter with Kotlin.
January 23, 2023
Spring Boot interaction with Kafka with HTTPS
In this article, we will be developing a Spring Boot application that works with Kafka and terminates traffic via HTTPS. So first of all we have to generate self-signed certificates by following the bash script. #!/bin/bash set -o nounset \ -o errexit \ -o verbose \ -o xtrace # Generate CA key openssl req -new -x509 -keyout snakeoil-ca-1.key -out snakeoil-ca-1.crt -days 365 -subj ‘/CN=localhost/OU=TEST/O=MEDIUM/L=PaloAlto/S=Ca/C=US’ -passin pass:medium -passout pass:medium # openssl req -new -x509 -keyout snakeoil-ca-2.
January 22, 2023
HashiCorp Vault - Getting started
Hi, there! It is a text version of the Vault webinar Let’s go! First of all, we have to download Vault or install it via your favorite packet manager. You can download the latest version of Vault from the official website — https://www.vaultproject.io/downloads Or simply install it via brew brew tap hashicorp/tap brew install hashicorp/tap/vault After successful installation, we can check that Vault in the PATH In this tutorial, we are going to use Consul as the backend for our Vault.
February 23, 2022
Stop writing code inside main method
Introduction Greetings to everyone who reads this post! Due to my work, I often run into novice programmers and look at their code. Sometimes it is beautiful, sometimes not, but I understand that a person learns, and the further he masters the best practices and technologies, the better his code becomes. But I would still like to pay some attention to such a simple task that almost all novice programmers face — writing a calculator.
November 29, 2020
Software architecture, 2
My previous blogpost start from the house picture — as analogy about architecture. But I found some problems with this analogy: There is no software construction industry in the same degree that there is for buildings. The building industry has substantial substructure, reflection numerous specialisations, skill sets, training paths, corporate organisations, standards bodies, and regulations. While the software industry has some structure, including that seen in offshore development practices, it is much less differentiated than the building industry The discipline off architecture does not have anything akin to the issue of deployment in software: Software is built in one place, but deployed for use in many places, often with specialisation and localisation.
November 28, 2020
Software architecture
Introduction In this article I will try to explain what is architecture, clean architecture, architector role in project Examples of web architecture application Let’s consider an example of a service with one architectural level (Single Tier) In an application with one architectural level, the user interface, business logic, that is, the backend part of the application and the database are on the same server An example of an application with one architectural level are applications such as MS Office, GIMP
November 24, 2020