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

This is an Elixir reimplementation of `:amqp_selective_consumer` -
[source](https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/amqp_client/src/amqp_selective_consumer.erl).

The module is used by default when you open a channel via
`AMQP.Channel.open/2` and allows you to end consumer processes via
`AMQP.Basic.consume/4` and receive messages from a queue.

Usually you don't have to pay attention to this module as the interaction
would be made through `AMQP.Channel.open/2`, `AMQP.Basic.consume/4`,
`AMQP.Basic.return/2`, `AMQP.Confirm.register_handler/2` etc.

# `t`

```elixir
@type t() :: %AMQP.SelectiveConsumer{
  confirm_handler: term(),
  consumers: %{required(String.t()) =&gt; pid()},
  default_consumer: pid() | :none,
  monitors: %{required(pid()) =&gt; {integer(), reference()}},
  return_handler: pid() | :none,
  unassigned: pid() | :undefined
}
```

# `register_default_consumer`

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

Ported from `:amqp_selective_consumer.register_default_consumer/2`.

This function registers a default consumer with the channel.

A default consumer is used when a subscription is made via
`amqp_channel:call(ChannelPid, #'basic.consume'{})` (rather than
`{@module}:subscribe/3`) and hence there is no consumer pid registered with
the consumer tag. In this case, the relevant deliveries will be sent to the
default consumer.

---

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