Skip to content

Instantly share code, notes, and snippets.

@alyx
Created February 7, 2013 06:33
Show Gist options
  • Save alyx/4728976 to your computer and use it in GitHub Desktop.
Save alyx/4728976 to your computer and use it in GitHub Desktop.
I'm sure this is fucko and broken as hell. Oh well.
-module(amanda).
-author("Alyx Wolcott <[email protected]>").
-include("amqp_client.hrl").
connect(Host, Port) ->
{ok, Queue} = start_amqp(),
{ok, Sock} = gen_tcp:connect(Host, Port, [{packet, line}]),
start_amqp() ->
{ok, Connection} = amqp_connection:start(#amqp_params_network{
username = "amanda",
password = "password",
virtual_host = "vhost",
host = "localhost"
}),
{ok, Channel} = amqp_connection:open_channel(Connection),
EDeclare = #'exchange.declare'{
exchange = <<"raw_irc">>,
type = <<"topic">>
},
#'exchange.declare_ok'{} = amqp_channel:call(Channel, EDeclare),
QDeclare = #'queue.declare'{},
#'queue.declare_ok'{queue = Queue} = amqp_channel:call(Channel, #'queue.declare'{}),
Binding = #'queue.bind'{
queue = Queue,
exchange = <<"raw_irc">>,
routing_key = <<"raw.out">>}
},
#'queue.bind_ok'{} = amqp_channel:call(Channel, Binding),
{ok, Queue}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment