Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update for rabbitmq api changes

  • Loading branch information...
commit 0c5722e2f1b1a017070dd55029d5ba7de76a52ce 1 parent 69c77b2
@brendonh authored
Showing with 23 additions and 31 deletions.
  1. +5 −6 evo/Makefile
  2. +16 −22 evo/src/evoamqp.erl
  3. +2 −3 evo/src/evoamqpcomet.erl
View
11 evo/Makefile
@@ -5,22 +5,21 @@ EBIN_DIR = ebin
INCLUDE_DIR = include
MOCHIWEB_EBIN = ../../mochiweb/ebin
-COMETD_EBIN = ../../cometd/ebin
-COUCHDB_EBIN = ../../../lib/erlang_couchdb/ebin
OPENID_EBIN = ../../erl_openid/ebin
SOURCES = $(wildcard $(SRC_DIR)/*.erl)
INCLUDES = $(wildcard $(INCLUDE_DIR)/*.hrl)
TARGETS = $(patsubst $(SRC_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES))
-RABBITMQ_INCLUDE = /usr/local/share/rabbitmq/include
+RABBITMQ_INCLUDE = /usr/lib/rabbitmq/lib/rabbitmq_server-1.7.1/include/
+RABBITMQ_CLIENT_INCLUDE = ../../rabbitmq-erlang-client/include
OPENID_INCLUDE = ../../erl_openid/src
-ERLC_INCLUDES = -I $(INCLUDE_DIR) -I $(RABBITMQ_INCLUDE) -I $(OPENID_INCLUDE)
+ERLC_INCLUDES = -I $(INCLUDE_DIR) -I $(RABBITMQ_INCLUDE) -I $(OPENID_INCLUDE) -I $(RABBITMQ_CLIENT_INCLUDE)
ERL_EBINS = -pa $(EBIN_DIR) \
- -pa $(MOCHIWEB_EBIN) -pa $(COMETD_EBIN) -pa $(COUCHDB_EBIN) -pa $(OPENID_EBIN)
+ -pa $(MOCHIWEB_EBIN) -pa $(OPENID_EBIN)
-ERLC = erlc
+ERLC = ERL_LIBS=../../rabbitmq-erlang-client/dist erlc
ERLC_OPTS = $(ERLC_INCLUDES) -o $(EBIN_DIR) -Wall -v +debug_info
ERL_CMD=erl \
View
38 evo/src/evoamqp.erl
@@ -10,8 +10,9 @@
-behaviour(gen_server).
-include("evo.hrl").
--include("rabbit.hrl").
--include("rabbit_framing.hrl").
+%-include("rabbit.hrl").
+%-include("rabbit_framing.hrl").
+-include("amqp_client.hrl").
%% API
-export([start_link/7]).
@@ -28,6 +29,11 @@
}).
+-define(BASIC_PROPERTIES,
+ #'P_basic'{content_type = <<"application/octet-stream">>,
+ delivery_mode = 1,
+ priority = 0}).
+
%%====================================================================
%% API
%%====================================================================
@@ -44,7 +50,10 @@ start_link(Name, Host, Port, User, Password, Realm, Exchange) ->
init([Host, Port, User, Password, Realm, Exchange]) ->
- Connection = amqp_connection:start_network(User, Password, Host, Port),
+ Params = #amqp_params{username=User, password=Password,
+ host=Host, port=Port},
+
+ Connection = amqp_connection:start_network(Params),
Channel = amqp_connection:open_channel(Connection),
Access = #'access.request'{realm = Realm,
@@ -137,10 +146,7 @@ handle_cast({send, Queue, Payload}, State) ->
routing_key = Queue,
mandatory = false,
immediate = false},
- Content = #content{class_id = 60,
- properties = amqp_util:basic_properties(),
- properties_bin = none,
- payload_fragments_rev = [Payload]},
+ Content = #amqp_msg{payload=Payload},
amqp_channel:cast(State#state.channel, BasicPublish, Content),
{noreply, State};
@@ -159,21 +165,9 @@ terminate(Reason, State) ->
?DBG({wtf, Reason}),
- ChannelClose
- = #'channel.close'{reply_code = 200,
- reply_text = <<"Goodbye">>,
- class_id = 0,
- method_id = 0},
- #'channel.close_ok'{}
- = amqp_channel:call(State#state.channel, ChannelClose),
-
- ConnectionClose
- = #'connection.close'{reply_code = 200,
- reply_text = <<"Goodbye">>,
- class_id = 0,
- method_id = 0},
- #'connection.close_ok'{}
- = amqp_connection:close(State#state.connection, ConnectionClose),
+ amqp_channel:close(State#state.channel),
+
+ amqp_connection:close(State#state.connection),
ok.
View
5 evo/src/evoamqpcomet.erl
@@ -8,8 +8,7 @@
-module(evoamqpcomet).
-include("evo.hrl").
--include("rabbit.hrl").
--include("rabbit_framing.hrl").
+-include("amqp_client.hrl").
%% Evo component callbacks
@@ -179,7 +178,7 @@ comet_loop(State) ->
comet_loop(State#state{queues=[ConsumerTag|State#state.queues]});
{#'basic.deliver'{consumer_tag=Tag, routing_key=Key},
- #content{payload_fragments_rev = [Payload]}} ->
+ #amqp_msg{payload=Payload}} ->
handle_amqp_message(State, {Tag, Key, Payload});
{listen_timeout, Pid} ->
Please sign in to comment.
Something went wrong with that request. Please try again.