In this post, I will show how we can use the annotation @ControllerAdvice — Controller Advice — an exception handler in the Spring Boot application. If you want to read how to handle uncaught exceptions in Spring Boot, you can check my old post.
Spring 3.2 introduced an annotation
@ControllerAdvice. The annotation allows the handling of exceptions across the application. Before this, Spring offered another annotation
@ExceptionHandler for exception handling. But, you have to add this annotation in each controller class of your application. It doesn't help on the application level.
@ControllerAdvice is an annotation-driven interceptor. …
In this post, I will show how we can use the API Gateway pattern with Spring Cloud. With microservice architecture becoming more and more useful, it has become equally complex how to handle calls to the microservices.
The purpose of microservices is to decouple the application into loosely coupled microservices that can interact with clients and with each other easily.
Importantly, the ease of development and deployment make microservices easier to design based on specific needs.
When the enterprise architecture scales, it becomes complicated with the number of microservices. …
In this post, I plan to show an example of Spring Boot Application authentication with AWS Cognito. I will show two flows 1) OIDC Authentication 2) SAML Authentication.
AWS Cognito is a web service from AWS. Cognito is a user directory as well as an authentication mechanism service. In the enterprise industry, every application has two requirements from a user perspective.
Cognito makes this easier by allowing the creation of a user pool or an identity pool. Once you have a pool, you can configure an application with the various settings for authentication. Another…
In this post, I cover everything you need to know about Spring Data JPA so you can use this library more confidently in your Spring Boot application. I have seen there are a lot of confusion about when to use
JpaRepository, so I will cover that as well.
As the official documentation from Spring says “Spring Data JPA makes it easy to implement JPA based repositories. It improves and eases the implementation of the JPA-based data access layer. Overall, data access applications are easier to implement.”
With Spring Data JPA, one can avoid a lot of boilerplate code…
In this post, I will show how we can achieve the conversion of entity to DTO using the ModelMapper library. We will basically create a simple REST API for
orders while showing the transformation of Entity to DTO and vice versa.
In most enterprise architecture, you will have REST APIs. A consumer of these APIs sends a request and the server responds with a response. The transformation of request to response happens behind the API. You perform business logic and modify these objects.
Traditionally, there are three layers in the architecture. Web layer, business layer, and database layer.
In this post, I will show the comparison of the two retries — Spring Retry vs Resilience4j Retry. Usually, you can combine retry with a circuit breaker when implementing to make your application more robust. I already covered the circuit breaker demo. Also, I have updated my book Simplifying Spring Security with Okta Demo if you are interested to learn more about Spring Security.
Spring Retry allows applications to retry a failed operation automatically. In most cases, if your service is calling another service and another service is not responding for some reason, you can use Spring Retry to retry…
In this post, I will show how we can deploy a spring boot application on AWS ECS (Elastic Container Service). ECS is one of the amazon web services that is mainly used to run the applications. It is an alternative to use EC2 instances directly.
ECS is a container orchestration service. ECS allows you to run your container. You can also easily build ECS cluster using AWS Farget. Farget removes the need to provision and manages a server. The advantage of using ECS is that you don’t have to decide which server EC2 instance to use, the service does that…
In this post, I will show how we can build user management and authentication with Okta SDK and Spring Boot.
As part of any application, developers have to be careful how they build authentication. Despite we are using Form-Based authentication for a long time, it is not the most secure one. In this post, I plan to show Form-Based authentication where users are not necessarily authenticated by validating their encrypted password against the password stored in a database. If you want to learn more about Spring Security with different authentication flows, I recently released a book Simplifying Spring Security. …
In this post, I will show how we can use the Circuit Breaker pattern in a Spring Boot Application. When I say Circuit Breaker pattern, it is an architectural pattern. Netflix had published a library Hysterix for handling circuit breakers. As part of this post, I will show how we can use a circuit breaker pattern using the resilence4j library in a Spring Boot Application.
The concept of Circuit Breaker comes from Electrical Engineering. In…
In this post, I want to show how you can use Spring Batch. This is a step by step Spring Batch Tutorial.
In enterprise applications, batch processing is common. But with data becoming more prevalent on the internet, it has also become important how we process this data. There are multiple solutions available. Apache Storm or Apache Spark helps with processing and transforming the data in the required format. In this post, we will be looking at Spring Batch more closely.
Spring Batch is a lightweight framework designed to facilitate batch processing. It allows developers to create batch applications. …
Software Developer, Writer