Skip to content

Commit

Permalink
Merge 8556d98 into 0c073d3
Browse files Browse the repository at this point in the history
  • Loading branch information
janrenz committed Dec 18, 2013
2 parents 0c073d3 + 8556d98 commit 7112c76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/msgr/binding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ class Binding
include Logging
attr_reader :connection, :route, :subscription, :dispatcher, :queue

def initialize(connection, route, dispatcher)
def initialize(connection, route, dispatcher, exchange)
@connection = connection
@route = route
@dispatcher = dispatcher

exchange = connection.exchange
@queue = connection.queue route.name

route.keys.each do |key|
log(:debug) { "Bind #{key} to #{@queue.name}." }

log(:debug) { "Bind #{key} to #{@queue.name} on exchange #{exchange.name}." }
queue.bind exchange, routing_key: key
end

Expand Down
4 changes: 2 additions & 2 deletions lib/msgr/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def stop(opts = {})
log(:info) { 'Terminated.' }
end

def publish(routing_key, payload)
@connection.publish payload, routing_key: routing_key
def publish(payload, routing_key)
@connection.publish payload, routing_key
end

private
Expand Down
4 changes: 3 additions & 1 deletion lib/msgr/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def rebind

def bind
# Create new bindings
routes.each { |route| bindings << Binding.new(Actor.current, route, dispatcher) }
routes.each { |route| bindings << Binding.new(Actor.current, route, dispatcher, exchange) }

log(:debug) { 'New routes bound.' }
end
Expand Down Expand Up @@ -101,6 +101,8 @@ def publish(payload, opts = {})

begin
payload = JSON.generate(payload)
log(:debug) {opts.inspect}
log(:debug) {exchange.name}
exchange.publish payload, opts.merge(persistent: true, content_type: 'application/json')
rescue => error
exchange.publish payload.to_s, opts.merge(persistent: true, content_type: 'application/text')
Expand Down

0 comments on commit 7112c76

Please sign in to comment.