Kombu.Exchange (Kombu v0.1.0)

Copy Markdown View Source

An Exchange declaration (kombu.entity.Exchange).

Summary

Functions

Converts the exchange into a dictionary/map representation (as_dict).

Raises Kombu.NotBoundError if neither exchange.channel nor channel is bound.

Returns a copy of exchange bound to channel.

Binds this exchange to source exchange (exchange.bind_to).

Creates a %Kombu.Binding{} for this exchange.

Returns true if the exchange is bound to a channel.

Returns true if declaration of this exchange can be cached (not auto_delete).

Returns true if this exchange should be declared on the broker. Exchanges with no_declare: true, empty name "", or starting with "amq." are not declared.

Declares the exchange on the broker channel if can_declare?/1 is true.

Deletes the exchange from the broker.

Returns the delivery modes mapping.

Compares two %Kombu.Exchange{} structs for value equality (ignoring channel binding).

Checks if two exchange declarations are equivalent (type, durable, auto_delete, arguments), matching kombu.transport.virtual.exchange.ExchangeType.is_equivalent.

Binds the exchange to channel if not already bound and channel is non-nil.

Normalizes a delivery mode ("transient", "persistent", :transient, :persistent, 1, 2) into its integer representation (1 or 2). Defaults to 2 (persistent) when nil.

Creates a prepared message map to be published to this exchange (Exchange.Message).

Constructs a %Kombu.Exchange{} struct, or returns an existing %Kombu.Exchange{} (optionally binding it to opts[:channel]).

Returns the persistent delivery mode constant (2).

Publishes a prepared message to the exchange. Accepts either publish(exchange, message, opts) or publish(exchange, message, routing_key, opts \ []).

Revives the exchange with a new channel (Exchange.revive).

Returns the transient delivery mode constant (1).

Unbinds this exchange from source exchange (exchange.unbind_from).

Types

t()

@type t() :: %Kombu.Exchange{
  arguments: map() | nil,
  auto_delete: boolean(),
  channel: Kombu.Channel.t() | nil,
  delivery_mode: 1 | 2 | nil,
  durable: boolean(),
  extra: map(),
  name: String.t(),
  no_declare: boolean(),
  passive: boolean(),
  routing_key: String.t() | nil,
  type: String.t()
}

Functions

as_dict(exchange, opts \\ [])

@spec as_dict(t(), keyword()) :: map()

Converts the exchange into a dictionary/map representation (as_dict).

assert_bound!(exchange, channel \\ nil)

@spec assert_bound!(t(), Kombu.Channel.t() | nil) :: Kombu.Channel.t()

Raises Kombu.NotBoundError if neither exchange.channel nor channel is bound.

bind(exchange, channel)

@spec bind(t(), Kombu.Channel.t() | nil) :: t()

Returns a copy of exchange bound to channel.

bind_to(exchange, source \\ "", opts \\ [])

@spec bind_to(t(), t() | String.t(), keyword()) :: term()

Binds this exchange to source exchange (exchange.bind_to).

binding(exchange, opts \\ [])

@spec binding(t(), keyword()) :: Kombu.Binding.t()

Creates a %Kombu.Binding{} for this exchange.

bound?(exchange)

@spec bound?(t()) :: boolean()

Returns true if the exchange is bound to a channel.

can_cache_declaration?(exchange)

@spec can_cache_declaration?(t()) :: boolean()

Returns true if declaration of this exchange can be cached (not auto_delete).

can_declare?(exchange)

@spec can_declare?(t()) :: boolean()

Returns true if this exchange should be declared on the broker. Exchanges with no_declare: true, empty name "", or starting with "amq." are not declared.

declare(exchange, opts \\ [])

@spec declare(t(), keyword()) :: term()

Declares the exchange on the broker channel if can_declare?/1 is true.

delete(exchange, opts \\ [])

@spec delete(t(), keyword()) :: term()

Deletes the exchange from the broker.

delivery_modes()

@spec delivery_modes() :: map()

Returns the delivery modes mapping.

equal?(a, b)

@spec equal?(t(), term()) :: boolean()

Compares two %Kombu.Exchange{} structs for value equality (ignoring channel binding).

equivalent?(a, b)

@spec equivalent?(t() | map(), t() | map()) :: boolean()

Checks if two exchange declarations are equivalent (type, durable, auto_delete, arguments), matching kombu.transport.virtual.exchange.ExchangeType.is_equivalent.

maybe_bind(exchange, channel)

@spec maybe_bind(t(), Kombu.Channel.t() | nil) :: t()

Binds the exchange to channel if not already bound and channel is non-nil.

maybe_delivery_mode(v, modes \\ %{1 => 1, 2 => 2, :persistent => 2, :transient => 1, "persistent" => 2, "transient" => 1}, default \\ 2)

@spec maybe_delivery_mode(term(), map(), 1 | 2) :: 1 | 2

Normalizes a delivery mode ("transient", "persistent", :transient, :persistent, 1, 2) into its integer representation (1 or 2). Defaults to 2 (persistent) when nil.

message(exchange, body, opts \\ [])

@spec message(t(), term(), keyword()) :: map()

Creates a prepared message map to be published to this exchange (Exchange.Message).

new(name_or_exchange \\ "", opts \\ [])

@spec new(t() | String.t() | nil, keyword()) :: t()

Constructs a %Kombu.Exchange{} struct, or returns an existing %Kombu.Exchange{} (optionally binding it to opts[:channel]).

persistent_delivery_mode()

@spec persistent_delivery_mode() :: 2

Returns the persistent delivery mode constant (2).

publish(exchange, message, routing_key_or_opts \\ [], extra_opts \\ [])

@spec publish(t(), map(), String.t() | keyword() | nil, keyword()) :: term()

Publishes a prepared message to the exchange. Accepts either publish(exchange, message, opts) or publish(exchange, message, routing_key, opts \ []).

revive(exchange, channel)

@spec revive(t(), term()) :: t()

Revives the exchange with a new channel (Exchange.revive).

transient_delivery_mode()

@spec transient_delivery_mode() :: 1

Returns the transient delivery mode constant (1).

unbind_from(exchange, source \\ "", opts \\ [])

@spec unbind_from(t(), t() | String.t(), keyword()) :: term()

Unbinds this exchange from source exchange (exchange.unbind_from).