Skip to content

Instantly share code, notes, and snippets.

@paulmooring
Created January 31, 2013 00:04
Show Gist options
  • Save paulmooring/4678588 to your computer and use it in GitHub Desktop.
Save paulmooring/4678588 to your computer and use it in GitHub Desktop.
bunnyc.erl snippet
%% @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