Tag: microservices

  • How to implement authorization using JWT/OAuth2 in Spring Boot?

    There are two main aspects in Security: Authentication deals with whether the user who tries to access an application is a legitimate user. Authorization deals with whether the user has rights to read/modify a particular resource in the application. In this post let us look into authorization in Spring Boot. Let us consider an application…

  • How to implement Circuit Breaker Design Pattern in Spring Boot?

    How to implement Circuit Breaker Design Pattern in Spring Boot?

    Table of Contents: Problem: Fault tolerance is a major requirement for enterprise applications. If your application gets huge load , how does it behave? If something wrong happens within your application and you still want to handle it gracefully , what do you do? Fault tolerance is especially important for microservices since many microservices communicate…

  • How to implement SAGA design pattern in Spring Boot?

    How to implement SAGA design pattern in Spring Boot?

    Contents: Problem: Microservices come with their own advantages and disadvantages. One such disadvantage is managing distributed transactions. Let’s say your transaction spans 4 different microservices. How do you ensure that your transaction either commits successfully with all the 4 tasks succeeding or fails successfully if any of the tasks is not completed ( the completed…

  • How to implement CQRS design pattern in Spring Boot?

    How to implement CQRS design pattern in Spring Boot?

    Contents Problem: Let’s say you run a large scale ecommerce store. You have a large user base who query your system for products much more than they buy them. In other words , your system has more read requests than write requests. And so you would like to handle the high load of read requests…

  • How to implement Event Sourcing in Spring Boot?

    How to implement Event Sourcing in Spring Boot?

    All our web applications deal with data. We store this data mostly in a database. The data which is stored thus represents the current state of the data. For example , if you have a Customer table the table will have entries which represent the current state of the customer (what their name is and…

  • How to implement Transactional Outbox design pattern in Spring Boot Microservices?

    How to implement Transactional Outbox design pattern in Spring Boot Microservices?

    Let’s say you have created a microservice. One of the APIs in the microservice does two operations: How can you make sure both are transactional? In other words if database update fails don’t send the message to the other service and if message sending fails rollback the database update? In Spring you handle transactions using…

  • How to implement distributed tracing using Spring Cloud Sleuth in Spring Boot?

    Microservices comes with many advantages. But there are disadvantages too. One of them is tracing the logs of your microservices. When there are so many microservices , user requests will span many of them and it will be difficult to trace the logs for a particular request when an issue occurs. To resolve this you…

  • How to do server side load balancing using Spring Cloud Gateway and Netflix Eureka?

    In this post we saw how to do client side load balancing in Spring Boot Microservices. One disadvantage of client side load balancing is every microservice client need to implement this load balancing. This might not be a big deal given how simple the changes required are. Still there is some coupling on the client…

  • How to do client side load balancing in Spring Boot?

    Let’s say you have created a set of microservices. They communicate to each other through a service registry like Eureka. One shortcoming in communicating through service registry is load balancing is not taken care of by default. You need to take care of that through a client side load balancer or a service side load…

  • How to talk to services in a service registry in Spring Boot?

    In this post we saw how to set up a service registry in Spring Boot. You can register all your microservices in a single service registry which will make it easier for each microservice to communicate with each other. In this post let’s see how to do the communication part. How can a microservice discover…