# `AMQP.Confirm`
[🔗](https://github.com/pma/amqp/blob/v4.2.1/lib/amqp/confirm.ex#L1)

Functions that work with publisher confirms (RabbitMQ extension to AMQP
0.9.1).

# `next_publish_seqno`

```elixir
@spec next_publish_seqno(AMQP.Channel.t()) :: non_neg_integer()
```

On channel with confirm activated, return the next message sequence number.

To use in combination with `register_handler/2`

# `register_handler`

```elixir
@spec register_handler(AMQP.Channel.t(), pid()) :: :ok
```

Register a handler for confirms on channel.

The handler will receive either:

  * `{:basic_ack, seqno, multiple}`

  * `{:basic_nack, seqno, multiple}`

The `seqno` (delivery_tag) is an integer, the sequence number of the message.

`multiple` is a boolean, when `true` means multiple messages confirm, up to
`seqno`.

See https://www.rabbitmq.com/confirms.html

# `select`

```elixir
@spec select(AMQP.Channel.t()) :: :ok | AMQP.Basic.error()
```

Activates publishing confirmations on the channel.

# `unregister_handler`

```elixir
@spec unregister_handler(AMQP.Channel.t()) :: :ok
```

Remove the return handler.

It does nothing if there is no such handler.

# `wait_for_confirms`

```elixir
@spec wait_for_confirms(AMQP.Channel.t()) :: boolean() | :timeout
```

Wait until all messages published since the last call have been either ack'd
or nack'd by the broker.

Same as `wait_for_confirms/2` but with the default timeout of 60 seconds.

# `wait_for_confirms`

```elixir
@spec wait_for_confirms(
  AMQP.Channel.t(),
  non_neg_integer() | {non_neg_integer(), :second | :millisecond}
) :: boolean() | :timeout
```

Wait until all messages published since the last call have been either ack'd
or nack'd by the broker, or until timeout elapses.

Returns `true` if all messages are ack'd. Returns `false` if *any* of the messages
are nack'd. Returns `:timeout` on timeouts.

`timeout` can be an integer or a tuple with the "time unit" (see the spec). If just an integer
is provided, it's assumed to be *in seconds*. This is unconventional Elixir/Erlang API
(since usually the convention is milliseconds), but we are forwarding to the underlying
AMQP Erlang library here and it would be a breaking change for this library to default
to milliseconds.

# `wait_for_confirms_or_die`

```elixir
@spec wait_for_confirms_or_die(AMQP.Channel.t()) :: true
```

Wait until all messages published since the last call have been either ack'd
or nack'd by the broker, or until timeout elapses.

If any of the messages were nack'd, the calling process dies.

Same as `wait_for_confirms_or_die/2` but with the default timeout of 60 seconds.

# `wait_for_confirms_or_die`

```elixir
@spec wait_for_confirms_or_die(
  AMQP.Channel.t(),
  non_neg_integer() | {non_neg_integer(), :second | :millisecond}
) :: true
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
