Spring Boot 3.2: Replace Your RestTemplate With RestClient

In the world of Spring Boot, making HTTP requests to external services is a common task. Traditionally, developers have relied on RestTemplate for this purpose. However, with the evolution of the Spring Framework, a new and more powerful way to handle HTTP requests has emerged: the WebClient. In Spring Boot 3.2, a new addition called RestClient builds upon WebClient, providing a more intuitive and modern approach to consuming RESTful services.

Origins of RestTemplate

RestTemplate has been a staple in the Spring ecosystem for years. It's a synchronous client for making HTTP requests and processing responses. With RestTemplate, developers could easily interact with RESTful APIs using familiar Java syntax. However, as applications became more asynchronous and non-blocking, the limitations of RestTemplate started to become apparent.

Building gdocweb With Java 21, Spring Boot 3.x, and Beyond

Starting a new project is always a mix of excitement and tough decisions, especially when you're stitching together familiar tools like Google Docs with powerhouses like GitHub Pages. This is the story of building gdocweb, a tool that I hoped would make life easier for many. I'll be diving into why I chose Java 21 and Spring Boot 3.x, ditched GraalVM after some trial and error, and why a simple VPS with Docker Compose won out over more complex options. I also went with Postgres and JPA, but steered clear of migration tools like Flyway. It's a no-frills, honest recount of the choices, changes, and the occasional "aha" moments of an engineer trying to make something useful and efficient.
gdocweb image

Introducing gdocweb

Before we dive into the technical intricacies and the decision-making labyrinth of building gdocweb, let's set the stage by understanding what gdocweb is and the problem it solves. In simple terms, gdocweb connects Google Docs to GitHub Pages. It's a simple web builder that generates free sites with all the raw power of GitHub behind it, and all the usability of Google Docs.

Going Full-Stack With Kotlin/JS and Spring Boot

In the dynamic world of web development, Single Page Applications (SPAs) and frameworks like React, Angular, and Vue.js have emerged as the preferred approach for delivering seamless user experiences. With the evolution of the Kotlin language and its recent multiplatform capabilities, new options exist that are worthwhile to evaluate.

In this article, we will explore Kotlin/JS for creating a web application that communicates with a Spring Boot backend which is also written in Kotlin. In order to keep it as simple as possible, we will not bring in any other framework. 

Best Practices for Multi-Module Projects With Spring Boot

Most applications in the real world will accumulate a large amount of features and code in the long run. Multi-module projects are a good approach to structuring the application without having to go down the complex path of microservices. The following five tips can help to better organize such Spring Boot projects in the long run.

#1 Find a Proper Module Structure

In general, the use of two modules, "base" and "web," is a good starting point for Spring Boot applications. The "base" module describes the basic setup, for example, database settings, and provides utility classes. Standards defined here then apply to all further modules. In "web," all modules are combined, and the executable application is built — our executable "fat jar."

Querydsl vs. JPA Criteria, Part 5: Maven Integration

As most technologies or dependencies evolve fast, it's sometimes hard to make the initial setup or upgrade smoothly. The goal of this article is to provide a summary of the Maven setup for the Querydsl framework, depending on the used technology. After that, let's see a short overview of the Querydsl solution.

In This Article, You Will Learn

  • How to setup Querydsl with Spring Boot 2.x (i.e Java EE) and Spring Boot 3.x (i.e. Jakarta EE)
  • What is a Maven classifier
  • How is the Maven classifier used in Querydsl build
  • Usage of Eclipse Transformer Plugin

Querydsl Setup

There are several possibilities to set up Querydsl framework in a Spring Boot application. The correct approach depends on the technologies used. 

Spring Boot and React in Harmony

For many full-stack developers, the combination of Spring Boot and React has become a staple in building dynamic business applications. Yet, while powerful, this pairing has its set of challenges. From type-related errors to collaboration hurdles, developers often find themselves navigating a maze of everyday issues.

Enter Hilla, a framework that aims to simplify this landscape. If Hilla hasn't crossed your radar yet, this article will provide an overview of what it offers and how it can potentially streamline your development process when working with Spring Boot and React.

Reactive Event Streaming Architecture With Kafka, Redis Streams, Spring Boot, and HTTP Server-Sent Events (SSE)

This article outlines a solution for streaming events from Kafka, forwarding them to Redis using its Stream API, and reading individual streams from Redis via its streaming API. The added complexity in this scenario is the need to stream events from an HTTP endpoint using Server-Sent Events (SSE) while ensuring that only events relevant to a specific client ID are processed and sent.

Problem Statement

Many companies have an existing Kafka infrastructure where events are being produced. Our goal is to set up a system that subscribes to Kafka messages but only processes events relevant to a specific client ID. These filtered events should be forwarded to Redis using its Stream API. Additionally, we need to establish an HTTP endpoint for Server-Sent Events (SSE) that allows the specified client to receive real-time event updates.

Develop a Geocaching Multiplayer Game Using Flutter, Spring Boot, Oracle Database Free Spatial, and OpenStreetMap

In this blog, I will show you how to quickly create a full-stack app using an extremely powerful, versatile, popular, and entirely free software stack consisting of Flutter, Spring Boot, Oracle Database with Spatial (SQL, JSON, and blockchain), and OpenStreetMap. All of the source is of course available here.

As a use case, I will create a multi-player game based on geocaching. (Fun fact, there are now more than 3.1 million active geocaches in 196 different countries and even space.)

Using Apache Pulsar and Spring Boot for Real-Time Stream Processing

Real-time stream processing has become a critical component of modern data-driven applications. Apache Pulsar is an open-source distributed messaging system that provides seamless horizontal scalability and low-latency processing of real-time data streams. Spring Boot is a popular Java framework that simplifies the process of building and deploying production-grade applications. In this article, we will explore how to use Apache Pulsar and Spring Boot for real-time stream processing. 

Getting Started With Apache Pulsar

The first step in building a real-time stream processing application with Pulsar is to set up a Pulsar cluster. A Pulsar cluster consists of one or more brokers that handle incoming data streams and route them to the appropriate consumers. Pulsar provides a simple and straightforward way to set up a cluster using the Pulsar CLI tool. 

Repeatable Database Updates via Liquibase

The main purpose of this tutorial is to present a way of detecting modifications to a stored Liquibase change set that was previously applied and execute it again automatically. In order to illustrate this, a small proof of concept is constructed gradually. In the first step, the application configures Liquibase as its migration manager and creates the initial database schema. Then, modifications are applied to the running version, and lastly, the repeatable script is introduced and enhanced.

Set-Up

  • Java 17
  • Spring Boot v.3.0.2
  • Liquibase 4.17.2
  • PostgreSQL 12.11
  • Maven

Proof of Concept

As PostgreSQL was chosen for the database layer of this service, first, a new schema is created (liquirepeat). This can be easily accomplished by issuing the following SQL command after previously connecting to the database.

Preventing Data Loss With Kafka Listeners in Spring Boot

Data loss is one of the biggest problems developers face when building distributed systems. Whether due to network issues or code bugs, data loss can have serious consequences for enterprises. In this article, we'll look at how to build Kafka listeners with Spring Boot and how to use Kafka's acknowledgment mechanisms to prevent data loss and ensure the reliability of our systems.

Apache Kafka

Apache Kafka is a distributed message platform used to store and deliver messages. Once a message is written to Kafka, it will be kept there according to a retention policy. The consumer groups mechanism is used to read out messages. The offset for each consumer group is used to understand the stage of message processing and to keep track of the progress of each consumer group in reading messages from a partition. It allows each consumer group to independently read messages from a topic and resume reading from where it left off in case of failures or restarts. In a simplified way, this can be represented as follows:
Apache Kafka process

Spring Boot and Time Series Data in ScyllaDB

The following tutorial walks you through how to use Spring Boot apps with ScyllaDB for time series data, taking advantage of shard-aware drivers and prepared statements. It’s a shorter version of a ScyllaDB University (self-paced free training) lab

About This Spring Boot and Time Series Data Tutorial

This tutorial provides a step-by-step demonstration of how to use the popular Spring Boot framework to build a sample stock application. ScyllaDB is used to store the stock price (time series data). The application has several APIs that support the create, get, and delete operations on stocks with the date and price. Additionally, an HTTP API tool, Postman, is used to interact with our application and to test the API functionality. By the end of the tutorial, you’ll have a running Spring Boot app that serves as an HTTP API server with ScyllaDB as the underlying data storage. You’ll be able to create stocks with prices and dates and get a list of stock items. And you’ll learn how ScyllaDB can be used to store time series data. Note that ScyllaDB University offers a number of videos with additional background that are helpful for this lesson. For example:

Spring Boot and Apache Kafka [Video Tutorials]

This article has a series of video tutorials about Spring Boot, explore:

  • Use Swagger to make your REST API's documentation interactive and accessible.
  • Custom objects can be sent and received in Kafka topics.
  • How you can consume messages from the Kafka server installed in Amazon EC2 Instance 
  • An example of using Spring Boot with Kafka producers and consumers, along with a REST client, to connect to a Kafka server running on an Amazon EC2 Instance
  • The producer and consumer exchange messages with the Kafka server on the Amazon EC2 Instance
  • Produce code to send Kafka messages to the Amazon EC2 instance server. 
  • Spring Kafka consumer and producer example with Spring Boot
  • Send/consume custom objects to/from an Apache Kafka server running on an Amazon EC2 Instance

Let's get started!

Spring Boot, Quarkus, or Micronaut?

As I talked about in my other article about some of the top Java REST API frameworks, in today's world of modern software development, REST API frameworks play a crucial role in developing efficient and scalable microservices. Java has several frameworks for developing REST APIs, but three of the most popular ones are Spring Boot, Quarkus, and Micronaut. In this article, we will compare these frameworks, their features, and their pros and cons.

Spring Boot

Spring Boot is a popular Java-based framework that is widely used for developing RESTful APIs. It is built on top of the Spring Framework and provides a simplified and opinionated approach to building microservices. Spring Boot provides a lot of built-in features and functionalities that make it easy to get started with microservices.

Spring Boot vs Eclipse Micro Profile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative

In this article, we’re going to compare some essential metrics of web applications using two different Java stacks: Spring Boot and Eclipse Micro Profile. More precisely, we’ll implement the same web application in Spring Boot 3.0.2 and Eclipse Micro Profile 4.2. These releases are the most recent at the time of this writing. Since there are several implementations of Eclipse Micro Profile, we’ll be using one of the most famous: Quarkus. At the time of this writing, the most recent Quarkus release is 2.16.2.

This mention is important regarding Eclipse Micro Profile because, as opposed to Spring Boot, which isn’t based on any specification and, consequently, the question of the implementation doesn’t exist, Eclipse Micro Profile has largely been adopted by many editors who provide different implementations, among which Quarkus, Wildfly, Open Liberty and Payara are from the most evangelical.