Flux AMQP v0.0.1 FluxAMQP.Consumer behaviour View Source

Module responsible to consume AMQP messages.

The main approach to consume is done by defining a module which use FluxAMQP.Consumer and implements routing_keys/0 and consume/3 functions:

defmodule MyApp.AMQP.Consumer do
  use FluxAMQP.Consumer

  @impl FluxAMQP.Consumer
  def routing_keys do
    [
      "route.example",
      {"another.route.example", "amq.direct"}
    ]
  end

  @impl FluxAMQP.Consumer
  def consume(channel, delivery_tag, routing_key, payload) do
    # Handle message
  end
end

If routing_keys/0 returns an empty list, FluxAMQP will try to extract the routing keys from the application :flux_amqp configuration.

Link to this section Summary

Link to this section Callbacks

Link to this callback

consume(channel, payload, meta)

View Source
consume(
  channel :: %AMQP.Channel{conn: term(), pid: term()},
  payload :: String.t(),
  meta :: map()
) :: atom()
Link to this callback

routing_keys()

View Source
routing_keys() :: [binary() | {binary(), binary()}]