aio_producer_simple_diagram.md
The AIOProducer implements a multi-component architecture designed for high-performance asynchronous message production while maintaining clean separation of concerns.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AIOProducer │ │BufferTimeout │ │ MessageBatch │
│ (Orchestrator) │ │ Manager │ │ (Value Object) │
├─────────────────┤ ├─────────────────┤ ├─────────────────┤
│ • produce() │───▶│ • timeout │ │ • immutable │
│ • flush() │ │ monitoring │ │ • type safe │
│ • orchestrate │ │ • mark_activity │ │ • clean data │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ ▲
▼ ▼ │
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ProducerBatch │ │ProducerBatch │ │CallbackManager │
│ Manager │───▶│ Executor │ │ (Unified Mgmt) │
├─────────────────┤ ├─────────────────┤ ├─────────────────┤
│ • create_batches│ │ • execute_batch │ │ • sync/async │
│ • group topics │ │ • thread pool │ │ • object pool │
│ • manage buffer │ │ • poll results │ │ • event loop │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│create_message │ │ ReusableMessage │
│ _batch() │ │ Callback Pool │
├─────────────────┤ ├─────────────────┤
│ • factory func │ │ • pooled objs │
│ • type safety │◄─────────────────────────│ • auto-return │
│ • validation │ │ • thread safe │
└─────────────────┘ └─────────────────┘
AIOProducer (main API)ProducerBatchManager, ProducerBatchExecutor, BufferTimeoutManagerCallbackManager (merged handler + pool)MessageBatch + factory functionAIOProducer receives produce() calls.ProducerBatchManager groups messages by topic/partition.ProducerBatchExecutor handles thread pool operations.BufferTimeoutManager ensures timely delivery.CallbackManager processes delivery reports on event loop.AIOProducer API, callback execution.src/confluent_kafka/aio/producer/_AIOProducer.pysrc/confluent_kafka/aio/producer/ directorysrc/confluent_kafka/aio/_common.pyThis architecture follows several key design principles:
Unlike the synchronous Producer which uses polling-based callbacks, the AIOProducer: