Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Extend purge_queue helper to ignore non-existing queues
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorszun committed Jun 20, 2018
1 parent bcd7932 commit ab3fdaa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/rabbit_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,22 @@ defmodule GenRMQ.RabbitCase do
AMQP.Connection.close(conn)
end

def purge_queues!(uri, queues) do
{:ok, conn} = rmq_open(uri)
Enum.each(queues, &purge_queue!(conn, &1))
AMQP.Connection.close(conn)
end

def purge_queue(conn, queue) do
try do
purge_queue!(conn, queue)
catch
:exit, _ ->
:ok
end
end

def purge_queue!(conn, queue) do
{:ok, chan} = AMQP.Channel.open(conn)
AMQP.Queue.purge(chan, queue)
AMQP.Channel.close(chan)
Expand Down

0 comments on commit ab3fdaa

Please sign in to comment.