async-event

Define async processing patterns with @Async, Virtual Threads, and @TransactionalEventListener.

Updated Jan 11, 2026
One-click install
npx skills add https://github.com/gykk16/spring-skeleton --skill async-event
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: async-event
Source: https://github.com/gykk16/spring-skeleton/tree/main/.omc/skills/async-event
Command: npx skills add https://github.com/gykk16/spring-skeleton --skill async-event

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear rules and best practices for implementing asynchronous operations and event-driven communication within Spring applications, ensuring robust, scalable, and maintainable code.

Core Features & Use Cases

  • Asynchronous Execution: Leverage @Async with Virtual Threads for non-blocking operations.
  • Transactional Event Handling: Use @TransactionalEventListener to trigger side effects reliably after transaction commits.
  • MDC Context Propagation: Ensure trace IDs and request context are preserved across asynchronous calls.
  • Use Case: When a new order is placed, you need to send a confirmation email and notify a Slack channel. This Skill ensures these actions happen asynchronously after the order is successfully saved to the database, without blocking the user's request.

Quick Start

Use the async-event skill to configure asynchronous processing for a new order creation event.

Frequently Asked Questions about async-event

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I trigger side effects asynchronously after a Spring transaction commits?

To trigger side effects after a Spring transaction commits, use `@TransactionalEventListener` combined with `@Async`. This ensures actions like sending emails execute reliably only after the database transaction succeeds.

How do I propagate MDC context across async virtual threads in Spring?

Propagating MDC context across async virtual threads in Spring requires explicit context passing within the `@Async` execution. This ensures trace IDs are preserved for request traceability in asynchronous event-driven processing.

Why does my transactional event listener execute before the database commit?

A transactional event listener might execute before the database commit due to incorrect event listener phasing. You must configure the listener to run specifically in the `AFTER_COMMIT` phase to avoid this pitfall.

What is the best way to handle external I/O within Spring database transactions?

The best way to handle external I/O within Spring database transactions is to extract it using event-driven design. Move the I/O operations to an `@Async` method triggered after the transaction commits.

Can I use @Async with virtual threads for non-blocking operations in Spring?

Yes, you can use `@Async` with virtual threads in Spring for non-blocking operations. This combination handles side effects concurrently without blocking the main user request thread.

What are the limitations of using @TransactionalEventListener for async processing?

Limitations of `@TransactionalEventListener` for async processing include potential MDC context loss and incorrect execution phasing if not explicitly configured. It also requires careful handling to avoid external I/O within the transaction.