Skip to content

Commit

Permalink
Make nanite work with RabbitMQ 1.8.
Browse files Browse the repository at this point in the history
The 1.8 version doesn't allow the declaration of an exchange with
different parameters anymore.

See "Exchange equivalence" at:
http://lists.rabbitmq.com/pipermail/rabbitmq-announce/2010-June/000025.html

This makes the simpleagent example work again.
  • Loading branch information
bernd committed Aug 10, 2010
1 parent 62d06cd commit 747359b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/nanite/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def receive(packet)
Nanite::Log.warn("RECV NOT AUTHORIZED #{packet.to_s}")
if packet.kind_of?(Request)
r = Result.new(packet.token, packet.reply_to, @deny_token, identity)
amq.queue(packet.reply_to, :no_declare => options[:secure]).publish(serializer.dump(r))
amq.queue(packet.reply_to, :durable => true, :no_declare => options[:secure]).publish(serializer.dump(r))
end
else
dispatcher.dispatch(packet)
Expand Down Expand Up @@ -222,7 +222,7 @@ def setup_queue

def setup_heartbeat
EM.add_periodic_timer(options[:ping_time]) do
amq.fanout('heartbeat', :no_declare => options[:secure]).publish(serializer.dump(Ping.new(identity, status_proc.call)))
amq.fanout('heartbeat', :durable => true, :no_declare => options[:secure]).publish(serializer.dump(Ping.new(identity, status_proc.call)))
end
end

Expand All @@ -246,14 +246,14 @@ def un_register
unless @unregistered
@unregistered = true
Nanite::Log.info("SEND [un_register]")
amq.fanout('registration', :no_declare => options[:secure]).publish(serializer.dump(UnRegister.new(identity)))
amq.fanout('registration', :durable => true, :no_declare => options[:secure]).publish(serializer.dump(UnRegister.new(identity)))
end
end

def advertise_services
reg = Register.new(identity, registry.services, status_proc.call, self.tags)
Nanite::Log.info("SEND #{reg.to_s}")
amq.fanout('registration', :no_declare => options[:secure]).publish(serializer.dump(reg))
amq.fanout('registration', :durable => true, :no_declare => options[:secure]).publish(serializer.dump(reg))
end

def parse_uptime(up)
Expand Down
4 changes: 2 additions & 2 deletions lib/nanite/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def publish(request, target)
old_target = request.target
request.target = target unless target == 'mapper-offline'
Nanite::Log.debug("SEND #{request.to_s([:from, :tags, :target])}")
amq.queue(target).publish(serializer.dump(request, enforce_format?(target)), :persistent => request.persistent)
amq.queue(target, :durable => true).publish(serializer.dump(request, enforce_format?(target)), :persistent => request.persistent)
ensure
request.target = old_target
end
Expand All @@ -89,7 +89,7 @@ def handle_ping(ping)
else
packet = Advertise.new(nil, ping.identity)
Nanite::Log.debug("SEND #{packet.to_s} to #{ping.identity}")
amq.queue(ping.identity).publish(serializer.dump(packet))
amq.queue(ping.identity, :durable => true).publish(serializer.dump(packet))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nanite/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def setup_offline_queue
end

def setup_message_queue
amq.queue(identity, :exclusive => true).bind(amq.fanout(identity)).subscribe do |msg|
amq.queue(identity, :durable => true).bind(amq.fanout(identity)).subscribe do |msg|
begin
msg = serializer.load(msg)
Nanite::Log.debug("RECV #{msg.to_s}")
Expand Down
2 changes: 1 addition & 1 deletion lib/nanite/nanite_dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def dispatch(deliverable)
if deliverable.kind_of?(Request)
r = Result.new(deliverable.token, deliverable.reply_to, r, identity)
Nanite::Log.debug("SEND #{r.to_s([])}")
amq.queue(deliverable.reply_to, :no_declare => options[:secure]).publish(serializer.dump(r))
amq.queue(deliverable.reply_to, :durable => true, :exclusive => false, :no_declare => options[:secure]).publish(serializer.dump(r))
end
r # For unit tests
end
Expand Down

0 comments on commit 747359b

Please sign in to comment.