Skip to content

Instantly share code, notes, and snippets.

@dersar00

dersar00/app.ex Secret

Created May 21, 2018 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dersar00/3ddc29c27c55e5f9bd77c53852e5cd2e to your computer and use it in GitHub Desktop.
Save dersar00/3ddc29c27c55e5f9bd77c53852e5cd2e to your computer and use it in GitHub Desktop.
defmodule Receive do
use MethodMissing
def wait_for_messages do
receive do
{:basic_deliver, payload, meta} ->
IO.puts " [x] Received #{payload}"
#IO.inspect meta.headers
Friends.PersonController.save()
wait_for_messages()
end
end
end
{:ok, connection} = AMQP.Connection.open
{:ok, channel} = AMQP.Channel.open(connection)
AMQP.Queue.declare(channel, "queue", durable: true)
AMQP.Basic.consume(channel, "queue", nil, no_ack: true)
AMQP.Exchange.declare(channel, "default_project", :topic, durable: true)
IO.puts " [*] Waiting for messages. To exit press CTRL+C"
Receive.wait_for_messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment