Yggdrasil.Subscriber.Adapter.RabbitMQ (Yggdrasil for RabbitMQ v6.0.0) View Source
Yggdrasil subscriber adapter for RabbitMQ. The name of the channel should be a tuple with the name of the exchange and the routing key. The exchange should be a topic (or any exchange that redirects to topic) e.g:
Subscription to channel:
iex(1)> name = {"amq.topic", "channel"}
iex(2)> channel = %Yggdrasil.Channel{name: name, adapter: :rabbitmq}
iex(3)> Yggdrasil.subscribe(channel)
:ok
iex(4)> flush()
{:Y_CONNECTED, %Yggdrasil.Channel{name: {"amq.topic", "channel"}, (...)}}Publishing message:
iex(5)> Yggdrasil.publish(channel, "foo")
:okSubscriber receiving message:
iex(6)> flush()
{:Y_EVENT, %Yggdrasil.Channel{name: {"amq.topic", "channel"}, (...)}, "foo"}The subscriber can also unsubscribe from the channel:
iex(7)> Yggdrasil.unsubscribe(channel)
:ok
iex(8)> flush()
{:Y_DISCONNECTED, %Yggdrasil.Channel{name: {"amq.topic", "channel"}, (...)}}
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Starts Elixir.Yggdrasil.Subscriber.Adapter.RabbitMQ with a channel and optional options.
Link to this section Types
Specs
t() :: %Yggdrasil.Subscriber.Adapter.RabbitMQ{
chan: rabbitmq_channel :: nil | pid(),
channel: channel :: Yggdrasil.Channel.t(),
client: client :: Yggdrasil.RabbitMQ.Client.t()
}
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Specs
start_link(Yggdrasil.Channel.t(), GenServer.options()) :: GenServer.on_start()
Starts Elixir.Yggdrasil.Subscriber.Adapter.RabbitMQ with a channel and optional options.