Quarkus Framework for Java

Fault Tolerance in Quarkus

Systems can face issues, including failures in one or more components. For example, external APIs and databases may fail. This can cause a major negative impact on the system, which is why there are ways to handle these failures. Quarkus uses the SmallRye Fault Tolerance specification to make the system more resilient. These techniques are…

Read More
Java

How to Grouping and restricting constraints using Bean Validation?

We already know that the Bean Validation specification is very helpful for performing validations. There is also the possibility of validating using groups. Imagine the following scenario: a DTO for products and another one for categories, as in the following example: When trying to register a product by specifying the category id, we encounter an…

Read More
Java

What is Java Bean Validation and how to use it?

Bean Validation is a specification for performing validations in Java and can have multiple implementations. To avoid writing repetitive validation code, Java provides Bean Validation (standard specified by JSR 380, also known as Jakarta Bean Validation), which allows applying rules directly to class attributes using annotations. When developing Java applications, it is common to validate…

Read More
Quarkus Framework for Java

How to create an interceptor in Quarkus?

When developing REST APIs, it’s common to want to intercept requests and responses to log information, validate data, or even apply business rules and security checks. In JAX-RS-based applications, like those using Quarkus, this is possible using request and response filters. In this post, we’ll explore how to implement a simple interceptor in Quarkus that…

Read More
Quarkus Framework for Java

How to use Kafka with Quarkus?

Apache Kafka is one of the most popular solutions for large-scale distributed event streaming. Its ability to handle high volumes of messages makes it ideal for event-driven architectures. In this post, you’ll learn how to use Kafka with Quarkus, a modern framework for cloud-native Java applications. Best of all: Quarkus’ Kafka support also works with…

Read More
Java

What are Checked vs Unchecked Exceptions in Java?

In Java, exceptions are part of the Throwable hierarchy and are used to signal abnormal situations during the execution of a program. Understanding how exceptions are structured helps in designing more robust and readable code. At the top of the hierarchy is the Throwable class, which has two direct subclasses: Checked Exceptions Checked exceptions are…

Read More
Java

What’s the difference between Concurrency and Parallelism?

Concurrency and Parallelism are important concepts for bringing more efficiency to software, but they do not mean the same thing. A software application can handle multiple tasks, and the way these tasks are processed differs in each concept. Concurrency Imagine the scenario where we have a software that needs to process multiple tasks, such as…

Read More
Java

How to avoid NullPointerException in Java using Optional?

Optional was introduced in Java 8 as a way to handle potentially null values more safely and expressively. It helps to avoid NullPointerException and makes the code more readable. Hands on Creating an Optional Optional can be created in several ways: Printing the results will show the following output. Checking for Value Presence Optional provides…

Read More
Java

How do @PostConstruct and @PreDestroy annotation work in java?

Methods annotated with @PostConstruct and @PreDestroy are commonly used in the lifecycle of beans managed by the container, such as in frameworks like Spring or Quarkus. An example of their use is opening and closing database connections. If you want to know more about Bean management in Spring, don’t hesitate to read this post. @PostConstruct…

Read More
Java

How do functional interfaces work in Java?

Functional Interfaces are a fundamental concept in functional programming introduced in Java 8. They are interfaces that have exactly one abstract method, allowing the use of lambda expressions and method references to make the code more concise and readable. They can be used in Streams, for example, and promote code reuse. We can find several…

Read More