Asynchronous API Calls: Spring Boot, Feign, and Spring @Async

The requirement was to hit an eternal web endpoint and fetch some data and apply some logic to it, but the external API was super slow and the response time grew linearly with the number of records fetched. This called for the need to parallelize the entire API call in chunks/pages and aggregate the data.

Our synchronous feign client:

Callback Hell and Reactive Patterns

One of the ways that I have better understood the usefulness of a Reactive Streams-based approach is how it simplifies a non-blocking IO call.

This post will be a quick walkthrough of the kind of code involved in making a synchronous remote call. Then, we will demonstrate how layering in non-blocking IO, though highly efficient in the use of resources (especially threads), introduces complications referred to as a callback hell and how a Reactive Streams-based approach simplifies the programming model.

20 Examples of Using Java’s CompletableFuture

This post revisits Java 8’s CompletionStage API and specifically its implementation in the standard Java library CompletableFuture. The API is explained by examples that illustrate the various behaviors, where each example focuses on one or two specific behaviors.

Since the CompletableFuture class implements the CompletionStage interface, we first need to understand the contract of that interface. It represents a stage of a certain computation which can be done either synchronously or asynchronously. You can think of it as just a single unit of a pipeline of computations that ultimately generates a final result of interest. This means that several CompletionStages can be chained together so that one stage’s completion triggers the execution of another stage, which in turn triggers another, and so on.

Tascalate Concurrent — Filling the Gaps in CompletableFuture API (Part 1)

The Tascalate Concurrent library provides an implementation of the CompletionStage interface and related classes. These are designed to support long-running blocking tasks (typically, I/O bound). This functionality augments the sole Java 8 built-in implementation, CompletableFuture, that primarily supports computational tasks. Also, the library helps with numerous asynchronous programming challenges like handling timeouts, retry/poll functionality, orchestrating results of multiple concurrent computations, and similar.

The library is shipped as a multi-release JAR and may be used both with Java 8 as a classpath library or with Java 9+ as a module.