View on GitHub
Registers a queue consumer process. The `pid` of the process can be set using
the `consumer_pid` argument and defaults to the calling process.
The consumer process will receive the following data structures:
* `{:basic_deliver, payload, meta}` - This is sent for each message consumed, where `payload` contains the message content and `meta` contains all the metadata set when sending with Basic.publish or additional info set by the broker;
* `{:basic_consume_ok, %{consumer_tag: consumer_tag}}` - Sent when the consumer process is registered with Basic.consume. The caller receives the same information as the return of Basic.consume;
* `{:basic_cancel, %{consumer_tag: consumer_tag, no_wait: no_wait}}` - Sent by the broker when the consumer is unexpectedly cancelled (such as after a queue deletion)
* `{:basic_cancel_ok, %{consumer_tag: consumer_tag}}` - Sent to the consumer process after a call to Basic.cancel
## Options
* `:consumer_tag` - Specifies the consumer tag for this consumer (as a string).
This tag is local to the given channel `chan`, so different channels can have
consumers that use the same consumer tag. If the given consumer tag is `""`,
then the server autogenerates the tag. Defaults to `""`.
* `:no_local` - If set, the server won't send messages to the connection
that published them. Defaults to `false`.
* `:no_ack` - If set, the server will not expect message acks from the consumer and
will consider every message that it believes was delivered to the consumer as
acknowledged. Defaults to `false`, meaning that messages need to be acked
explicitly through `ack/3`.
* `:exclusive` - If set, requests exclusive consumer access, meaning that only
this consumer can consume from the given `queue`. Note that the client cannot
have exclusive access to a queue that already has consumers.
* `:no_wait` - If set, the consume operation is asynchronous. Defaults to
`false`.
* `:arguments` - A list of arguments to pass when consuming (of type `t:AMQP.arguments/0`).
See the README for more information. Defaults to `[]`.