# Auto Ack (/sdks/rust/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 calling `receive_queue_messages` with `is_peek` set to `false`. With it enabled, delivery and acknowledgment happen as one atomic step on the broker side, so there's no separate ack call and no in-flight "pending" state for the message to sit in.

**Gotchas:** if your consumer crashes or panics 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/rust/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, the `max_messages` and `wait_timeout` arguments are your only throttles — there's no visibility-timeout window to tune.

## Prerequisites [#prerequisites]

* KubeMQ server running on `localhost:50000`
* Rust SDK installed (`cargo add kubemq`)

## Code [#code]

```rust title="main.rs"
use kubemq::prelude::*;
use kubemq::QueueMessageBuilder;

#[tokio::main]
async fn main() -> kubemq::Result<()> {
    let client = KubemqClient::builder()
        .host("localhost")
        .port(50000)
        .build()
        .await?;

    let channel = "rust-queues.auto-ack";

    let msg = QueueMessageBuilder::new()
        .channel(channel)
        .body(b"auto-ack-message".to_vec())
        .build();
    client.send_queue_message(msg).await?;

    let messages = client.receive_queue_messages(channel, 10, 5, false).await?;
    for m in &messages {
        println!("Auto-acked: id={}, body={}", m.id, String::from_utf8_lossy(&m.body));
    }

    client.close().await?;
    Ok(())
}
```

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

* The simple receive API (`is_peek=false`) automatically acknowledges messages on delivery.
* No explicit ack call is needed — the server marks messages as consumed.
* Review timeouts, channel names, and client IDs before running against shared environments.
* Run the program while the server from the prerequisites is available.

## Related [#related]

* [Queues overview](/learn/queues)
* [Rust SDK Reference](/sdks/rust/reference/queues)
* [Ack & Reject](/sdks/rust/how-to/queues/ack-reject)
