devto 2026-09-30 원문 보기 ↗
Day 10 of the WKafka Open-Source Engineering Series.
Calling a slow external API inside a standard synchronous Kafka consumer is a recipe for missed heartbeats. WKafka supports async def natively.
@kafka.consumer(topic="webhooks", format="json")
async def on_webhook(msg):
# Non-blocking asynchronous outbound HTTP dispatch
async with httpx.AsyncClient() as client:
await client.post(msg.value["url"], json=msg.value["payload"])
Tested and verified with Apache Kafka against real broker clusters (see EXAMPLES_STATUS.md in repository). Compatible with Python 3.9 through 3.14 with strict typing.