Skip to main content

Module 21: Async Client

The reactive, non-blocking version of Module 01.

What You’ll Learn

  • AcpClient.async() instead of AcpClient.sync()
  • Chaining operations with Mono and flatMap
  • Async session update consumers returning Mono<Void>
  • When to use async vs sync

The Code

Sync vs Async Comparison

The async client wraps every operation in Project Reactor’s Mono. If you’re already using a reactive framework, the async client integrates naturally. For CLI tools and scripts, the sync client is simpler.

Alternative: block()

For scripts where you want async types but don’t care about non-blocking I/O:
This defeats the purpose of async but can be useful during prototyping.

Source Code

View on GitHub

Running the Example

Next Module

Module 22: Async Agent — build an agent with reactive handlers.