ExRabbitMQAdmin.Exchange (ex_rabbitmq_admin v0.1.4)

View Source

RabbitMQ Exchanges.

Summary

Functions

Delete a specific exchange under a virtual host by name.

Get an individual exchange by name under a virtual host.

List all bindings in which the given exchange is the destination.

List all bindings in which the given exchange is the source.

List all exchanges on the RabbitMQ cluster.

List all exchanges in a given virtual host. Optionally pass pagination parameters to filter exchanges.

Publish a message to the given exchange. Please not that this is not an optimal way to publish messages to a queue. Consider using a library like AMQP.

Create a new exchange under a virtual host with given name.

Functions

delete_exchange(client, vhost, name, opts \\ [])

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

Delete a specific exchange under a virtual host by name.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, required: true
  • name - type: string, required: true
  • :if_unused (boolean/0) - If true, prevent deleting the exchange if it is bound to a queue or acts as a source for another exchange.

get_exchange(client, vhost, name)

@spec get_exchange(
  client :: Tesla.Client.t(),
  vhost :: String.t(),
  name :: String.t()
) :: {:ok, Tesla.Env.t()} | no_return()

Get an individual exchange by name under a virtual host.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, required: true
  • name - type: string, required: true

list_exchange_dest_bindings(client, vhost, name)

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

List all bindings in which the given exchange is the destination.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, required: true
  • name - type: string, required: true

list_exchange_src_bindings(client, vhost, name)

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

List all bindings in which the given exchange is the source.

Params

  • client - Tesla client used to perform the request.
  • vhost - type: string, required: true
  • name - type: string, required: true

list_exchanges(client, opts \\ [])

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

List all exchanges 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_exchanges(client, vhost, opts \\ [])

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

List all exchanges in a given virtual host. Optionally pass pagination parameters to filter exchanges.

Params

  • client - Tesla client used to perform the request.

  • vhost - type: string, required: true

  • :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.

publish_message(client, vhost, name, opts \\ [])

Publish a message to the given exchange. Please not that this is not an optimal way to publish messages to a queue. Consider using a library like AMQP.

Params

  • client - Tesla client used to perform the request.

  • vhost - type: string, required: true

  • name - type: string, required: true

  • :properties (map of String.t/0 keys and term/0 values) - Message properties. The default value is %{}.

  • :routing_key (String.t/0) - Required. The routing key used to route the message to its destination.

  • :payload - Required. Message to be sent.

  • :payload_encoding - If set to string the payload will be sent as an UTF-8 encoded string. If base64, the message payload should be base64 encoded. The default value is :string.

If the message is published successfully to at least one queue, it will respond with:

%{"routed" => true}

put_exchange(client, vhost, name, opts \\ [])

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

Create a new exchange under a virtual host with given name.

Params

  • client - Tesla client used to perform the request.

  • vhost - type: string, required: true

  • name - type: string, required: true

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

  • :auto_delete (boolean/0) - If true, the exchange is auto-deleted once the last bound object is unbound from the exchange. The default value is false.

  • :durable (boolean/0) - Durable exchanges survives server restarts and lasts until explicitly deleted. The default value is true.

  • :internal (boolean/0) - Internal exchanges are meant for internal RabbitMQ tasks only. The default value is false.

  • :type - Exchange types defines how messages are routed by using different parameters and bindings. The default value is :direct.