# Auto Ack (/sdks/python/how-to/queues/auto-ack)



## Overview [#overview]

**Auto-ack** is the fire-and-forget receive mode for queues: the broker marks a message as consumed the instant it hands it to your client, instead of waiting for your code to settle it. Reach for it when the work is idempotent, low-value, or cheap to lose — a metrics ping, a cache warm, a best-effort notification — and you'd rather not carry the bookkeeping of explicit acknowledgment for every message.

It works by passing `auto_ack=True` to `receive_queue_messages`. With it enabled, delivery and acknowledgment happen as one atomic step on the broker side, so there's no separate `msg.async_ack()` call and no in-flight "pending" state for the message to sit in.

**Gotchas:** if your consumer crashes or raises after `receive_queue_messages` returns but before it finishes processing, that message is gone for good — auto-ack gives you no chance to nack or requeue it, unlike [Ack & Reject](/sdks/python/how-to/queues/ack-reject). It's an at-most-once model, so never use it for messages where losing one silently would matter. And because acknowledgment happens on delivery, `max_messages` and `wait_timeout_seconds` are your only throttles — there's no visibility-timeout window to tune.

## Prerequisites [#prerequisites]

* KubeMQ server running on `localhost:50000`
* Python SDK installed (`pip install kubemq`)

## Code [#code]

```python title="auto_ack.py"
"""Example: Auto ack — receive messages with automatic acknowledgment."""

from __future__ import annotations

import asyncio

from kubemq import AsyncQueuesClient, QueueMessage


async def main() -> None:
    async with AsyncQueuesClient(
        address="localhost:50000",
        client_id="python-queues-stream-auto-ack-client",
    ) as client:
        await client.send_queue_message(
            QueueMessage(
                channel="python-queues-stream.auto-ack",
                body=b"auto-acked-message",
            )
        )

        response = await client.receive_queue_messages(
            channel="python-queues-stream.auto-ack",
            max_messages=10,
            wait_timeout_seconds=5,
            auto_ack=True,
        )
        for msg in response.messages:
            print(
                f"Received (auto-acked): id={msg.id}, "
                f"body={msg.body.decode('utf-8')}"
            )
        print("Messages were automatically acknowledged upon receipt")


if __name__ == "__main__":
    asyncio.run(main())

```

## How It Works [#how-it-works]

* `auto_ack=True` tells the broker to acknowledge all returned messages automatically at the time of delivery, without requiring explicit `msg.async_ack()` calls.
* Messages acknowledged automatically are immediately removed from the queue; there is no opportunity to nack or requeue them.
* This mode is appropriate for idempotent consumers or situations where at-most-once delivery is acceptable.
* Without `auto_ack`, each message stays in a visibility-timeout state until explicitly settled, providing at-least-once delivery semantics.

## Related [#related]

* [Pattern overview](/learn/queues/getting-started)
* [Python SDK Reference](/sdks/python/reference/queues)
* [Send & Receive](/sdks/python/tutorials/send-receive)
* [Ack All](/sdks/python/how-to/queues/ack-all)
