Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Message always publish to localhost. Reuse base 'channel' method to publ... #14

Merged
merged 1 commit into from almost 2 years ago

3 participants

Pavel Drobushevich Marek Michael Klishin
Pavel Drobushevich

...ish and subscribe on one instance (via change connection host to not localhost).

Pavel Drobushevich pavel-drobushevich Message always publish to localhost. Reuse base 'channel' method to p…
…ublish and subscribe on one instance (via change connection host to not localhost).
961b21b
Marek
Owner
majek commented

I'm not a ruby person. What's the difference?

Pavel Drobushevich

Old code call following method:
AMQP::Exchange.default
Source code for this method:
https://github.com/ruby-amqp/amqp/blob/master/lib/amqp/exchange.rb (line 149 and below)
This method has one argument - channel to connect, If this argument is not provided exchange creates default channel which connects to localhost. It is not expected, because FibonacciRpcClient has own channel and in my case it was configured to remote RabbitMQ installation, but as result message try to send to default localhost channel (I don't have local instance).
There are two possible:
1. Use exist channel to create exchange
self.channel.default_exchange
2. Send exist channel to this method
AMQP::Exchange.default(self.channel)

Michael Klishin
Owner

The idea is to not allocate a new channel implicitly. In practical terms, it makes no difference for tutorials but may lead to people doing this unknowingly in real world code, over and over.

Marek majek merged commit 248e69f into from
Marek majek closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 18, 2012
Pavel Drobushevich pavel-drobushevich Message always publish to localhost. Reuse base 'channel' method to p…
…ublish and subscribe on one instance (via change connection host to not localhost).
961b21b
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  ruby/rpc_client.rb
2  ruby/rpc_client.rb
@@ -33,7 +33,7 @@ def call(n, &block)
33 33 corr_id = rand(10_000_000).to_s
34 34 self.requests[corr_id] = nil
35 35 self.callback_queue.append_callback(:declare) do
36   - AMQP::Exchange.default.publish(n.to_s, :routing_key => "rpc_queue", :reply_to => self.callback_queue.name, :correlation_id => corr_id)
  36 + self.channel.default_exchange.publish(n.to_s, :routing_key => "rpc_queue", :reply_to => self.callback_queue.name, :correlation_id => corr_id)
37 37
38 38 EM.add_periodic_timer(0.1) do
39 39 # p self.requests

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.