From b6f1ba7c90b7fb5a294bba87f9d6f875d432984c Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Fri, 3 May 2013 23:35:42 -0700 Subject: [PATCH] Return and save the AMQP Channel pid. --- amqp/amqp_bot_listener.erl | 2 +- irc/irc_amqp_listener.erl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/amqp/amqp_bot_listener.erl b/amqp/amqp_bot_listener.erl index bd8a934..a0732b3 100644 --- a/amqp/amqp_bot_listener.erl +++ b/amqp/amqp_bot_listener.erl @@ -42,4 +42,4 @@ listen_for_events(RoutingKeyString) -> no_ack = true }, Pid), - {ok, ConsumerTag}. + {ok, ConsumerTag, Channel}. diff --git a/irc/irc_amqp_listener.erl b/irc/irc_amqp_listener.erl index ceca5aa..da33e92 100644 --- a/irc/irc_amqp_listener.erl +++ b/irc/irc_amqp_listener.erl @@ -25,8 +25,8 @@ start_link(ConnectionPid, RoutingKey) -> gen_server:start_link(?MODULE, {ConnectionPid, RoutingKey}, []). init({ConnectionPid, RoutingKey}) -> - {ok, _} = amqp_bot_listener:listen_for_events(RoutingKey), - {ok, {ConnectionPid}}. + {ok, _, ListeningChannel} = amqp_bot_listener:listen_for_events(RoutingKey), + {ok, {ConnectionPid, ListeningChannel}}. %% Ignore the message indicating that the listener is operating correctly handle_info(#'basic.consume_ok'{}, State) -> @@ -35,7 +35,7 @@ handle_info(#'basic.consume_ok'{}, State) -> handle_info( { #'basic.deliver'{routing_key = RoutingKey}, #amqp_msg{payload = BinContent} }, - State = {ConnectionPid}) -> + State = {ConnectionPid, ListeningChannel}) -> error_logger:info_msg("Got a message ~p for routing key ~p~n", [BinContent, RoutingKey]), [_, _, DestinationKey] = string:tokens(binary_to_list(RoutingKey), "."), -- 2.11.0