Created
November 9, 2017 22:30
-
-
Save leikind/7f1721d706646343527962e233c1debd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Connection.open(amqp_url) do | |
{:error, reason} -> # pattern matching | |
Logger.error(["Cannot establish connection to RabbitMQ, reason:", inspect(reason)]) | |
{:error, reason} | |
{:ok, connection} -> # pattern matching | |
{:ok, channel} = Channel.open(connection) # pattern matching | |
Exchange.declare(channel, @exchange, :fanout) | |
{:ok, %{queue: queue_name}} = Queue.declare(channel, "", exclusive: true) # pattern matching | |
Queue.bind(channel, queue_name, @exchange) | |
{:ok, _consumer_tag} = Basic.consume(channel, queue_name, nil, no_ack: true) # pattern matching | |
channel | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment