conejo v0.3.3 Conejo.Consumer behaviour
Conejo.Consumer
is the behaviour which will help you to implement your own RabbitMQ consumers.
Configuration
Conejo.Consumer needs a configuration in the environment files.
Example:
config :my_application, :consumer,
exchange: "my_exchange",
exchange_type: "topic",
queue_name: "my_queue",
queue_declaration_options: [{:auto_delete, true}, {:exclusive, true}],
queue_bind_options: [routing_key: "example"],
consume_options: [no_ack: true]
Definition
defmodule MyConsumer do
use Conejo.Consumer
def handle_consume(_channel, payload, _params) do
IO.inspect payload
end
end
Start Up
options = Application.get_all_env(:my_application)[:consumer]
{:ok, consumer} = MyConsumer.start_link(options, [name: :consumer])
Summary
Callbacks
It will be executed after a message is received