Created
January 31, 2013 00:04
-
-
Save paulmooring/4678588 to your computer and use it in GitHub Desktop.
bunnyc.erl snippet
This file contains hidden or 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
%% @private | |
handle_call({publish, Key, Message, Opts}, _From, | |
State = #bunnyc_state{channel=Channel, exchange=Exchange}) | |
when is_binary(Key), is_binary(Message) orelse ?is_message(Message), | |
is_list(Opts) -> | |
Resp = internal_publish(fun amqp_channel:call/3, | |
Channel, Exchange, Key, Message, Opts), | |
{reply, Resp, State}; | |
handle_call({get, NoAck}, _From, | |
State = #bunnyc_state{channel=Channel, queue=Queue}) -> | |
Resp = internal_get(Channel, Queue, NoAck), | |
{reply, Resp, State}; | |
handle_call(stop, _From, | |
State = #bunnyc_state{channel=Channel, connection=Connection}) -> | |
amqp_channel:close(Channel), | |
amqp_connection:close(Connection), | |
{stop, normal, ok, State}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment