Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a conflict between amq-client and amq-protocol settings #26

Closed
temochka opened this issue Sep 18, 2013 · 7 comments
Closed

There is a conflict between amq-client and amq-protocol settings #26

temochka opened this issue Sep 18, 2013 · 7 comments

Comments

@temochka
Copy link

If amq/settings is loaded before amq/client then AMQ::Client::Settings.parse_amqp_url will raise a NoMethodError exception.

This is caused by improperly referencing Ruby built-in URI module at line 139 which gets overridden by AMQ::URI defined in the amq-protocol (which is not compatible with Ruby URI module).

Steps to reproduce:

I. Create an empty project with following Gemfile and run bundle install:

source 'https://rubygems.org'

gem 'amq-client', '1.0.2'

Produced Gemfile.lock is:

GEM
  remote: https://rubygems.org/
  specs:
    amq-client (1.0.2)
      amq-protocol (>= 1.2.0)
      eventmachine
    amq-protocol (1.8.0)
    eventmachine (1.0.3)

PLATFORMS
  ruby

DEPENDENCIES
  amq-client (= 1.0.2)

II. Run bundle exec irb and follow these steps:

1.9.3p392 :001 > require 'amq/settings'
 => true 
1.9.3p392 :002 > require 'amq/client'
 => true 
1.9.3p392 :003 > AMQ::Client::Settings.parse_amqp_url('amqp://localhost:5672')
NoMethodError: undefined method `scheme' for {:scheme=>"amqp", :host=>"localhost", :port=>5672, :ssl=>nil}:Hash
    from /Users/tema/.rvm/gems/ruby-1.9.3-p392/gems/amq-client-1.0.2/lib/amq/client/settings.rb:140:in `parse_amqp_url'
    from (irb):3
    from /Users/tema/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
1.9.3p392 :004 > 

Let me know if you need any additional info about the issue. I’m not sure if it makes sense to send a pull request (since the lib is not supported anymore), but the current stable version of the amqp gem relies on both amq-client and amq-protocol, so this might cause issues for others (as it did for us).

@michaelklishin
Copy link
Member

amqp gem 1.1 is just around the corner. Thanks for reporting.

@classicist
Copy link

In point of fact, the ordering of amqp/client and amqp settings does not matter. Below is the reverse of @temochka s example:
1.9.3p392 :001 > require 'amq/client'
=> true
1.9.3p392 :002 > require 'amq/settings'
=> true
1.9.3p392 :003 > AMQ::Client::Settings.parse_amqp_url('amqp://localhost:5672')
NoMethodError: undefined method scheme' for {:scheme=>"amqp", :host=>"localhost", :port=>5672, :ssl=>nil}:Hash from /Users/paul/.rvm/gems/ruby-1.9.3-p392/gems/amq-client-1.0.2/lib/amq/client/settings.rb:140:inparse_amqp_url'
from (irb):3
from /Users/paul/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `

'

@classicist
Copy link

Does anyone know a work around for this?

@michaelklishin
Copy link
Member

Use amqp gem 1.1.0-rc1. GA is a few days away.

@michaelklishin
Copy link
Member

If you need to parse an amqp(s) URI, simply use amq/uri in amq-protocol 1.8.0+. I will cut a new amq-client release, too, even though it's no longer being maintained.

@michaelklishin
Copy link
Member

amq-client 1.0.3 is out, URI parsing is now delegated to amq-protocol.

irb -Ilib

2.0.0-p247 :001 > require 'amq/client'
 => true
2.0.0-p247 :002 > require 'amq/settings'
 => false
2.0.0-p247 :003 > AMQ::Client::Settings.parse_amqp_url('amqp://localhost:5672')
 => {:scheme=>"amqp", :host=>"localhost", :port=>5672, :ssl=>nil}
2.0.0-p247 :004 > AMQ::Client::VERSION
 => "1.0.4.wip"

@classicist
Copy link

Excellent! Thank you both for the quick reply and for your excellent work on this gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants