This guide contains examples that show you how to serialize and deserialize from Java to JSON. It covers the basics and the most common use cases: Strings, Objects, Dates, Optionals, Lists, Maps, etc.
In this post, I’ll show you how to write more readable Unit Tests using a Behavior-Driven Development style (BDD). This is a coding style that is very easy to adopt and, at the same time, brings a huge benefit: it increases your test readability (a lot). Besides, it’s a small change that may drive you to go full-BDD (i.e. writing your test scenarios before your code).
With a practical example, you’ll see how to make this change with two very popular libraries: Mockito (and its BDDMockito implementation) and AssertJ.
Microservices are not always the solution
We, as developers, make mistakes. For example, one of the most common ones is thinking that a new technical solution or paradigm will solve all the problems existing in a given Software Project. That won’t happen, but we’ll be tempted anyway to fall into this trap. Microservices Architecture is one of the most popular traps.
In this post, you’ll learn how to set up Spring Boot 2 applications to build a Eureka cluster for Service Registration, and how to make use of Service Discovery via clients that can get each other’s information through the Eureka Registry.
This post uses a practical example to compare two different approaches to asynchronous tasks in Java: Future and CompletableFuture. It also includes the synchronous alternatives so you know the differences when using these asynchronous APIs.
In this guide, you’ll learn with an example of how the Flow API in Java 9 can help you build Reactive patterns with the new Publisher and Subscriber interfaces. After reading it, you should be able to understand this new programming style and its pros and cons. All the code is on GitHub so you can also run it yourself or try some modifications.
In this post, we’ll use Docker to create an image of a Spring Boot application and run it in a container. We’ll start with a single Dockerfile, then we’ll also cover how to scale our application using Docker Compose, and we’ll see how to build our Java code using Docker.
Microservices are getting very popular these days. This type of software architecture has a lot of advantages like flexibility and ease at scale. Mapping them into small teams in an organization also gives a lot of efficiency in development.
However, going on the adventure of microservices knowing only the benefits is a wrong call. You need to know what are the new paradigms and changes that you will face and prepare for that in advance. Books and articles can provide you with some knowledge but, when you get hands-on-code, the story changes.
If you use Ribbon and Eureka in your Spring Boot application, you’ll notice that the default configuration is not optimal. Eureka takes a long time to figure out that the service went down unexpectedly and, in the meantime, your load balancer Ribbon will try to connect to the dead one. In other words, the eviction policy does not perform well by default.
On the other hand, the official Eureka documentation discourages changing the
leaseRenewalIntervalInSeconds parameter so, what can we do here? This post answers that question.
When we work with a Gateway Service like Zuul, probably we want to include a Circuit Breaker mechanism to avoid ugly errors in case of redirecting to a service which is unavailable or not responding in time. We can do that by connecting Hystrix with Zuul with a
ZuulFallbackProvider bean. Let’s see how.