Nowadays software development is a challenging task as the number of programming languages, frameworks, libraries are increasing rapidly day by day. Luckily, the number of resources to learn on the internet for free also increased a lot. There are a ton of free resources to learn almost everything on the internet. There are lots of official documentation, blog posts, Udemy courses, YouTube videos etc. As a backend developer who primarily work on JVM based languages/frameworks like Java, Kotlin, SpringBoot etc, following are a collection of resources I usually follow to learn new things.
Continue reading »Remote debugging SpringBoot application
We all know how to run SpringBoot application in debug mode from our favorite IDEs(Eclipse/IntellijIDEA etc) and debug the code. Recently I had to debug a SpringBoot application which is running on a remote server. There is already lot of information on the Internet on how to remote debug java applications, but some approaches didn’t work for me. So, here I would like to share my findings. If application is running on localhost Suppose you are running your application on localhost only and remote debug from your IDE.
Continue reading »SpringBoot Integration Testing using TestContainers Starter
One of the many reasons for huge popularity of Spring and SpringBoot is it’s great support for Testing. We can write unit tests using Mockito without requiring any Spring features. And, we can write Integration Tests using Spring testing support by creating Spring ApplicationContext. Read Guide to Testing SpringBoot Applications While running integration tests we might need to interact with external services like relational databases, NoSQL datastores, Kafka etc. We can spin up those external services as Docker containers and run tests against them.
Continue reading »Creating Yeoman based SpringBoot Generator
I have been working with Spring and SpringBoot for many years and I needed to create lot of Spring(Boot) applications for various reasons like blog posts, sample apps, book sample code and for my personal learning as well. So, I needed some tool/mechanism to quickly create Spring(Boot) application with most commonly used configuration. I know we have the most popular SpringBoot Initializer to create SpringBoot applications. But, it generates the application with only selected starter dependencies added and nothing more.
Continue reading »Testing SpringBoot Applications
SpringBoot is the most popular tech stack for building Java based REST APIs. In this tutorial we will learn how to write tests for SpringBoot applications. Create SpringBoot Application Unit Testing using JUnit 5 and Mockito Integration Testing using TestContainers Testing MicroService Integrations using MockServer As we all know, we write unit tests for testing single component (a class) behaviour where as we write integration tests for testing a feature which may involve interaction with multiple components.
Continue reading »Kafka Tutorial - Producer and Consumer using SpringBoot
In the previous post Kafka Tutorial - Java Producer and Consumer we have learned how to implement a Producer and Consumer for a Kafka topic using plain Java Client API. In this post we are going to look at how to use Spring for Kafka which provides high level abstraction over Kafka Java Client API to make it easier to work with Kafka. You can find the source code for this article at https://github.
Continue reading »SpringBoot Best Practices
I have been working with SpringBoot for many years and over the time I worked with many SpringBoot based codebases. There are few common mistakes that I observe in the projects that use SpringBoot. So, I thought of writing down few good practices that can be followed while using SpringBoot. 1. Understand SpringBoot Core Concepts I know, this sounds very obvious but I see many developers jumping onto using SpringBoot without having any prior knowledge on Spring, Dependency Injection.
Continue reading »MicroServices - Part 6 : Distributed Tracing with Spring Cloud Sleuth and Zipkin
One of the challenges in microservices architecture is the ability to debug issues. A simple user action might trigger a chain of downstream microservice calls. It would be tedious to trace the logs related to a particular user action across microservices. In addition to that, we might want to track down why a certain microservice call is taking so much time. We can use Spring Cloud Sleuth to handle these kinds of issues.
Continue reading »MicroServices - Part 5 : Spring Cloud Zuul Proxy as API Gateway
In microservices architecture, there could be a number of API services and few UI components that are talking to APIs. As of now, many microservices based application still use monolithic front-ends where the entire UI is built as a single module. You may choose to go with micro-frontends where the UI is also decomposed into multiple microservice talking to APIs to get the relevant data. Instead of letting UI know about all our microservices details we can provide a unified proxy interface that will delegate the calls to various microservices based on URL pattern.
Continue reading »MicroServices - Part 4 : Spring Cloud Circuit Breaker using Netflix Hystrix
In the microservices world, to fulfill a client request one microservice may need to talk to other microservices. We should minimize this kind of direct dependencies on other microservices but in some cases it is unavoidable. If a microservice is down or not functioning properly then the issue may cascade up to the upstream services. Netflix created Hystrix library implementing Circuit Breaker pattern to address these kinds of issues. We can use Spring Cloud Netflix Hystrix Circuit Breaker to protect microservices from cascading failures.
Continue reading »