amqp: set the auto_delete bit on queues.
authorMatt Mullins <mmullins@mmlx.us>
Wed, 20 May 2015 04:31:25 +0000 (21:31 -0700)
committerMatt Mullins <mmullins@mmlx.us>
Wed, 20 May 2015 04:46:51 +0000 (21:46 -0700)
Without this, AMQP queues are leaked whenever we reconnect to an ircd.
Exclusive queues are only deleted when the connection is torn-down;
auto-deleted queues are also deleted when the last (i.e. only in this case)
conusmer is removed.

Since the AMQP consumers are tied to processes running under the irc_object_sup
for the IRC connection, these will be torn-down when we reconnect to the ircd.

amqp/amqp_bot_listener.erl

index a0732b3..829d147 100644 (file)
@@ -30,7 +30,7 @@ listen_for_events(RoutingKeyString) ->
                              type = <<"topic">>
                            }),
     #'queue.declare_ok'{ queue = Queue } = amqp_channel:call(Channel,
-        #'queue.declare'{ exclusive = true }),
+        #'queue.declare'{ exclusive = true, auto_delete = true }),
     #'queue.bind_ok'{} = amqp_channel:call(Channel,
         #'queue.bind'{ exchange = ?EXCHANGE,
                        queue = Queue,