ExRabbitMQAdmin.Queue (ex_rabbitmq_admin v0.1.4)

View Source

This module contains functions for interacting with RabbitMQ queues.

Summary

Functions

Delete an existing queue under a virtual host.

Get an individual queue under a virtual host by name.

List all bindings for a queue under a virtual host.

List all queues running on the RabbitMQ cluster.

List all queues in a given virtual host running on the RabbitMQ cluster.

Perform an action on a queue.

Purge all messages on a queue under a virtual host.

Create a new queue under a virtual host.

Receive messages from a queue under a virtual host. Please not that this is not an optimal way to consume messages from a queue. Consider using a library like AMQP.

Functions

delete_queue(client, vhost, queue, opts \\ [])

@spec delete_queue(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  queue :: String.t(),
  params :: Keyword.t()
) :: {:ok, Tesla.Env.t()} | no_return()

Delete an existing queue under a virtual host.

Params

  • client - Tesla client used to perform the request.

  • vhost - type: string, Virtual host for the queue.

  • queue - type: string, Name of the queue to delete.

  • :if_empty (boolean/0) - If true, prevent deleting the queue if it contains any messages. This option is not supported by quorum queues.

  • :if_unused (boolean/0) - If true, prevent deleting the queue if it has any consumers. This option is not supported by quorum queues.

get_queue(client, vhost, queue)

@spec get_queue(client :: Tesla.Client.t(), vhost :: String.t(), queue :: String.t()) ::
  {:ok, Tesla.Env.t()} | {:error, term()}

Get an individual queue under a virtual host by name.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, Virtual host for the queue.
  • queue - type: string, Name of the queue to get.

list_queue_bindings(client, vhost, queue)

@spec list_queue_bindings(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  queue :: String.t()
) :: {:ok, Tesla.Env.t()} | {:error, term()}

List all bindings for a queue under a virtual host.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, Virtual host for the queue.
  • queue - type: string, Name of the queue to get bindings for.

list_queues(client, opts \\ [])

@spec list_queues(client :: Tesla.Client.t(), opts :: Keyword.t()) ::
  {:ok, Tesla.Env.t()} | no_return()

List all queues running on the RabbitMQ cluster.

Params

  • client - Tesla client used to perform the request.

  • :page (non_neg_integer/0) - Page number to fetch if paginating the results.

  • :page_size (non_neg_integer/0) - Number of elements per page, defaults to 100.

  • :name (String.t/0) - Filter by name, for example queue name, exchange name, etc.

  • :use_regex (boolean/0) - Enables regular expression for the param name.

list_vhost_queues(client, vhost, opts \\ [])

@spec list_vhost_queues(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  opts :: Keyword.t()
) ::
  {:ok, Tesla.Env.t()} | no_return()

List all queues in a given virtual host running on the RabbitMQ cluster.

Params

  • client - Tesla client used to perform the request.

  • vhost - Name of the virtual host.

  • :page (non_neg_integer/0) - Page number to fetch if paginating the results.

  • :page_size (non_neg_integer/0) - Number of elements per page, defaults to 100.

  • :name (String.t/0) - Filter by name, for example queue name, exchange name, etc.

  • :use_regex (boolean/0) - Enables regular expression for the param name.

perform_queue_action(client, vhost, queue, atom)

@spec perform_queue_action(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  queue :: String.t(),
  action :: :sync | :cancel_sync
) :: {:ok, Tesla.Env.t()} | {:error, term()}

Perform an action on a queue.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, Virtual host for the queue.
  • queue - type: string, Name of the queue to perform actions for.
  • action - type: atom, Action to perform. Currently only supports :sync and :cancel_sync

purge_queue(client, vhost, queue)

@spec purge_queue(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  queue :: String.t()
) :: {:ok, Tesla.Env.t()} | {:error, term()}

Purge all messages on a queue under a virtual host.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, Virtual host for the queue.
  • queue - type: string, Name of the queue to purge messages from.

put_queue(client, vhost, queue, opts \\ [])

@spec put_queue(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  queue :: String.t(),
  opts :: Keyword.t()
) :: {:ok, Tesla.Env.t()} | no_return()

Create a new queue under a virtual host.

Params

  • client - Tesla client used to perform the request.

  • vhost - type: string, Virtual host for the queue.

  • queue - type: string, Name of the queue to get.

  • :auto_delete (boolean/0) - If true, automatically delete the queue when the last consumer disconnects. The default value is false.

  • :durable (boolean/0) - If true, messages are persisted on disk. This can lead to lower throughput, but better data consistency. The default value is true.

  • :node (String.t/0) - If set, start the queue on given node name.

  • :arguments (map of String.t/0 keys and term/0 values) - Optional queue arguments (x-arguments) passed to RabbitMQ when creating the queue. Please consult the official documentation for supported arguments (as they vary for queue type and installed plugins).

receive_queue_messages(client, vhost, queue, opts \\ [])

@spec receive_queue_messages(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  queue :: String.t(),
  opts :: Keyword.t()
) :: {:ok, Tesla.Env.t()} | no_return()

Receive messages from a queue under a virtual host. Please not that this is not an optimal way to consume messages from a queue. Consider using a library like AMQP.

Params

  • client - Tesla client used to perform the request.

  • vhost - type: string, Virtual host for the queue.

  • queue - type: string, Name of the queue to receive messages from.

  • :count (pos_integer/0) - Maximum number of messages to receive. You may get fewer messages if the queue cannot immediately provide them. The default value is 1.

  • :ackmode - Required. Determines if the messages will be removed from the queue. If set to ack_requeue_true or reject_requeue_true, the messages will be re-queued. If set to ack_requeue_false, or reject_requeue_false, they will be removed.

  • :encoding - If set to auto, message payload will be returned as string if it is valid UTF-8, or base64 encoded otherwise. If set to base64 message payload will always be base64 encoded. The default value is :auto.

  • :truncate (pos_integer/0) - If present, truncate the message payload if larger than given size (in bytes).