Tag: microservices

  • How to fetch configuration data from config server in Spring Boot?

    Let’s say you have created a Spring Boot application and you fetch properties from application.yml file. Every time you want to change a property you need to restart your application. And if there are few more projects having similar configuration you need to replicate the properties in those applications as well. To solve this ,…

  • 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 protect your Spring Boot microservice with OAuth2?

    Protecting your microservice developed in Spring Boot is quite forward. Spring does all the major work for you. Here are the steps to follow: STEP 1: Add spring boot starter oauth2 resource server dependency STEP 2: Configure Authorization Server STEP 3: Test STEP 1: Add spring boot starter oauth2 resource server dependency Add the below…

  • How to set up KeyCloak for OAuth2 client credentials flow?

    We live in the age of microservices. Microservices are often deployed as REST APIs. And the most popular way to protect and access these REST APIs is through OAuth2 protocol. And in OAuth2 protocol ,the preferred way to protect REST APIs is through client credentials. To set this, You first need an Identity and Access…

  • How to create a custom Health Check in Spring Boot for Microservices?

    Let’s say you have three microservices in your application. One of the microservices connects to the other two microservices. And in addition it also connects to a database. You want to check the health status of this microservice and its dependent microservices and database. How to do this in Spring Boot? Spring Boot provides an…

  • How to trace distributed logs using Spring Cloud Sleuth?

    In the previous post, I explained how to trace logs across distributed applications/microservices using MDC design pattern provided by all major logging frameworks like slf4j. Spring Boot has made it even easier. You just need to include the dependency spring-cloud-sleuth and do some minor changes and your logs are automatically appended with tracing ids .The…

  • How to trace logs across distributed applications/microservices in Spring Boot?

    Logging is so critical to applications. Good logging strategy can help you fix issues in production environment quickly and help you save time and money. With the adoption of microservices , proper logging has got even more importance. One of the difficulties in debugging microservices is that the flow of API requests are spread across…