Build reactive applications - WebFlux, Mono/Flux, R2DBC, backpressure, reactive streams
Build non-blocking APIs with Spring WebFlux, Project Reactor, and R2DBC. Use when creating reactive controllers, handling streaming data with SSE/WebSockets, or implementing backpressure strategies for high-performance applications.
/plugin marketplace add pluginagentmarketplace/custom-plugin-spring-boot/plugin install spring-boot-assistant@pluginagentmarketplace-spring-bootThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyMaster reactive programming with Spring WebFlux, Project Reactor, R2DBC, and reactive streams patterns.
This skill covers building non-blocking, reactive applications with Spring WebFlux and Project Reactor.
| Name | Type | Required | Default | Validation |
|---|---|---|---|---|
reactive_db | enum | ✗ | r2dbc-postgresql | r2dbc-postgresql | r2dbc-mysql | mongodb |
streaming | enum | ✗ | - | sse | websocket | rsocket |
backpressure | enum | ✗ | buffer | buffer | drop | latest |
@RestController with Mono<T> and Flux<T>@RestController
@RequestMapping("/api/users")
@RequiredArgsConstructor
public class UserController {
private final UserService userService;
@GetMapping
public Flux<UserResponse> findAll() {
return userService.findAll().map(UserResponse::from);
}
@GetMapping("/{id}")
public Mono<ResponseEntity<UserResponse>> findById(@PathVariable Long id) {
return userService.findById(id)
.map(UserResponse::from)
.map(ResponseEntity::ok)
.defaultIfEmpty(ResponseEntity.notFound().build());
}
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public Mono<UserResponse> create(@Valid @RequestBody Mono<CreateUserRequest> request) {
return request.flatMap(userService::create).map(UserResponse::from);
}
}
public interface UserRepository extends ReactiveCrudRepository<User, Long> {
Mono<User> findByEmail(String email);
Flux<User> findByActiveTrue();
@Query("SELECT * FROM users WHERE created_at > :since")
Flux<User> findRecentUsers(@Param("since") LocalDateTime since);
}
@Service
@RequiredArgsConstructor
@Transactional
public class UserService {
private final UserRepository userRepository;
public Mono<User> create(CreateUserRequest request) {
return userRepository.findByEmail(request.email())
.flatMap(existing -> Mono.<User>error(new DuplicateEmailException()))
.switchIfEmpty(Mono.defer(() -> {
User user = new User(request.email(), request.name());
return userRepository.save(user);
}));
}
public Flux<User> findAll() {
return userRepository.findAll()
.timeout(Duration.ofSeconds(5))
.onErrorResume(TimeoutException.class, e -> Flux.empty());
}
}
@RestController
@RequestMapping("/api/events")
public class EventController {
private final Sinks.Many<Event> eventSink = Sinks.many()
.multicast().onBackpressureBuffer();
@GetMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ServerSentEvent<Event>> stream() {
return eventSink.asFlux()
.map(e -> ServerSentEvent.<Event>builder()
.id(e.id())
.event(e.type())
.data(e)
.build());
}
@PostMapping
public Mono<Void> publish(@RequestBody Event event) {
return Mono.fromRunnable(() -> eventSink.tryEmitNext(event));
}
}
Transformation: map(), flatMap(), flatMapMany()
Filtering: filter(), take(), skip(), distinct()
Combination: merge(), concat(), zip()
Error: onErrorResume(), onErrorReturn(), retry(), timeout()
Side Effects: doOnNext(), doOnError(), doFinally(), log()
| Issue | Diagnosis | Fix |
|---|---|---|
| Nothing happens | Not subscribed | Return Mono/Flux from controller |
| Blocking error | Blocking in reactive | Use subscribeOn(Schedulers.boundedElastic()) |
| Memory issues | Unbounded buffer | Add backpressure strategy |
□ Verify Mono/Flux is returned (not subscribed manually)
□ Check for blocking calls (JDBC, Thread.sleep)
□ Review backpressure strategy
□ Enable Reactor debug: Hooks.onOperatorDebug()
□ Use .log() operator for debugging
@WebFluxTest(UserController.class)
class UserControllerTest {
@Autowired
private WebTestClient webTestClient;
@MockBean
private UserService userService;
@Test
void shouldReturnUsers() {
when(userService.findAll()).thenReturn(Flux.just(
new User(1L, "john@test.com", "John")));
webTestClient.get().uri("/api/users")
.exchange()
.expectStatus().isOk()
.expectBodyList(UserResponse.class)
.hasSize(1);
}
@Test
void shouldReturn404WhenNotFound() {
when(userService.findById(1L)).thenReturn(Mono.empty());
webTestClient.get().uri("/api/users/1")
.exchange()
.expectStatus().isNotFound();
}
}
Skill("spring-reactive")
| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2024-12-30 | R2DBC, SSE, WebTestClient patterns |
| 1.0.0 | 2024-01-01 | Initial release |
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.