Tag: springboot

  • How to implement Reactive Programming in Spring Boot?

    How to implement Reactive Programming in Spring Boot?

    Programming comes in different paradigms. For long , we did procedural programming using languages like C where the business logic was executed step by step in a procedural manner. Then came Object Oriented Programming where you modeled your business requirement into domain objects. It represented real world more closely and has been quite successful even…

  • 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…

  • How to set up a Service Registry in Spring Boot?

    Let’s say you have created few microservices. They talk to each other. You manually configure the URL of each microservice which each microservice talks to. You add them in application.yml files. Maintaining them can be difficult. And if there are multiple instances of each microservice , you may need to configure each instance URL or…

  • How to invoke OAuth2 protected microservice using WebClient in Spring Boot?

    Let’s say you want to call an OAuth2 protected microservice from your Spring Boot microservice application. Spring Boot as usual does majority of the work for us. We just need to add a dependency ,some configuration and using a single HTTP call using Spring Web Client we can invoke the microservice. Before that , to…

  • How to restrict users from uploading huge files in Spring Boot?

    Let’s say you have created a REST API which accepts files as input. You deployed the API and users started uploading huge files and your server’s memory gets fast filled up. How do you prevent this? You can do this with zero code changes in Spring Boot. All you have to do is add a…

  • How to deal with optional request parameters in Spring Boot?

    Let’s say you are creating a REST API in Spring Boot which accepts request parameters. You use the annotation @RequestParam to retrieve the request values. And if user does not supply the request parameter Spring will throw error. What if the request parameter is just an optional parameter? How to handle this in Spring ?…