amq-client-0.9.3/ 0000755 0001750 0001750 00000000000 11771004303 013055 5 ustar tfheen tfheen amq-client-0.9.3/README.textile 0000644 0001750 0001750 00000006254 11771004303 015421 0 ustar tfheen tfheen h2. About amq-client amq-client is a fully-featured, low-level AMQP 0.9.1 client that runs on Ruby 1.8.7, 1.9.2, REE, Rubinius and JRuby. It's sweet spot is in serving as foundation for higher-level, more opinionated AMQP libraries. It can be used directly by applications code when performance and access to advanced AMQP protocol features is more important that API convenience. h2(#amqp_gems_family). How does amq-client relate to amqp gem, amq-protocol and libraries like bunny?
|--------------| |-----------------------| |----------------------| | amq-protocol | | amq-client | | amqp gem, bunny, etc | | - Encoding | ===> | - IO abstraction | ===> | - high-level API | | - Decoding | | - Low-level AMQP API | | - opinionated | | | | - Framing | | | |--------------| |-----------------------| |----------------------|* At the lowest level, "amq-protocol gem":http://github.com/ruby-amqp/amq-protocol takes care of encoding, decoding and framing. * One level above is "amq-client gem":http://github.com/ruby-amqp/amq-client that takes care of network I/O, provides uniform interface for various I/O libraries like "EventMachine":http://rubyeventmachine.com/, "cool.io":http://coolio.github.com/ or good old TCP sockets and implements AMQP protocol entities (queues, exchanges, channels and so on) with emphasis on access to every feature available over API convenience or conciseness. * Finally, end applications use libraries like "amqp gem":http://github.com/ruby-amqp/amqp or "bunny AMQP client":http://github.com/ruby-amqp/bunny h2. Adapters Currently implemented adapters: * "EventMachine":http://github.com/eventmachine/eventmachine * "cool.io":http://coolio.github.com/ h3. EventMachine adapter At this point EventMachine adapter is feature-complete, well-tested, supports 5 Ruby implementations (1.8.7, 1.9.2, JRuby, Rubinius, Ruby Enterprise Edition) plus Microsoft Windows(tm) and is used by amqp gem starting with version 0.8.0. h3. cool.io adapter cool.io adapter is on par with EventMachine but is not used by any popular libraries (that we know of). Note that cool.io doesn't work on JRuby and Microsoft Windows(tm). h2. Installation amq-client is available from rubygems.org:
gem install amq-clientIf you use Bundler and want to use the very latest version, add this to your Gemfile:
gem "amq-client", :git => "https://github.com/ruby-amqp/amq-client.git"
h2. Pre-prelease versions
Pre-release versions are available from rubygems.org:
gem install amq-client --preh2. See also * "API documentation":http://rdoc.info/github/ruby-amqp/amq-client/master/frames * "Examples":https://github.com/ruby-amqp/amq-client/tree/master/examples/ * Stop by #rabbitmq on irc.freenode.net. You can use "Web IRC client":http://webchat.freenode.net?channels=rabbitmq if you don't have IRC client installed. * "Ruby AMQP mailing list":http://groups.google.com/group/ruby-amqp * "Issue tracker":http://github.com/ruby-amqp/amq-client/issues * "Continous integration server":http://travis-ci.org/#!/ruby-amqp/amq-client amq-client-0.9.3/amq-client.gemspec 0000755 0001750 0001750 00000002331 11771004303 016456 0 ustar tfheen tfheen #!/usr/bin/env gem build # encoding: utf-8 require "base64" require File.expand_path("../lib/amq/client/version", __FILE__) Gem::Specification.new do |s| s.name = "amq-client" s.version = AMQ::Client::VERSION.dup s.authors = ["Jakub Stastny", "Michael S. Klishin", "Theo Hultberg", "Mark Abramov"] s.email = [Base64.decode64("c3Rhc3RueUAxMDFpZGVhcy5jeg==\n"), "michael@novemberain.com"] s.homepage = "http://github.com/ruby-amqp/amq-client" s.summary = "amq-client is a fully-featured, low-level AMQP 0.9.1 client" s.description = "amq-client is a fully-featured, low-level AMQP 0.9.1 client with pluggable networking I/O adapters (EventMachine, cool.io, Eventpanda and so on) and supposed to back more opinionated AMQP clients (such as amqp gem) or be used directly in cases when access to more advanced AMQP 0.9.1 features is more important that convenient APIs" # files s.files = `git ls-files`.split("\n").reject { |file| file =~ /^vendor\// || file =~ /^gemfiles\// } s.require_paths = ["lib"] s.extra_rdoc_files = ["README.textile"] + Dir.glob("doc/*") # Dependencies s.add_dependency "eventmachine" s.add_dependency "amq-protocol", ">= 0.9.1" # RubyForge s.rubyforge_project = "amq-client" end amq-client-0.9.3/spec/ 0000755 0001750 0001750 00000000000 11771004303 014007 5 ustar tfheen tfheen amq-client-0.9.3/spec/benchmarks/ 0000755 0001750 0001750 00000000000 11771004303 016124 5 ustar tfheen tfheen amq-client-0.9.3/spec/benchmarks/adapters.rb 0000644 0001750 0001750 00000004364 11771004303 020263 0 ustar tfheen tfheen # encoding: utf-8 Bundler.setup Bundler.require(:default) $LOAD_PATH.unshift(File.expand_path("../../../lib", __FILE__)) require "amq/client/adapters/coolio" require "amq/client/adapters/event_machine" require "amq/client/queue" require "amq/client/exchange" TOTAL_MESSAGES = 10000 # Short messages # Cool.io coolio_start = Time.now AMQ::Client::CoolioClient.connect(:port => 5672, :vhost => "/amq_client_testbed") do |client| received_messages = 0 channel = AMQ::Client::Channel.new(client, 1) channel.open { } queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) { } queue.bind("amq.fanout") { } queue.consume(true) do |_, consumer_tag| queue.on_delivery do |_, header, payload, consumer_tag, delivery_tag, redelivered, exchange, routing_key| received_messages += 1 if received_messages == TOTAL_MESSAGES client.disconnect do Coolio::Loop.default.stop end end end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) TOTAL_MESSAGES.times do |i| exchange.publish("Message ##{i}") end end end cool.io.run coolio_finish = Time.now # Eventmachine em_start = Time.now EM.run do AMQ::Client::EventMachineClient.connect(:port => 5672, :vhost => "/amq_client_testbed") do |client| received_messages = 0 channel = AMQ::Client::Channel.new(client, 1) channel.open { } queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) { } queue.bind("amq.fanout") { } queue.consume(true) do |_, consumer_tag| queue.on_delivery do |_, header, payload, consumer_tag, delivery_tag, redelivered, exchange, routing_key| received_messages += 1 if received_messages == TOTAL_MESSAGES client.disconnect do EM.stop end end end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) TOTAL_MESSAGES.times do |i| exchange.publish("Message ##{i}") end end end end em_finish = Time.now puts "Results for #{TOTAL_MESSAGES} messages:" puts "\tcool.io adapter: #{sprintf("%.3f", coolio_finish - coolio_start)}s" puts "\teventmachine adapter: #{sprintf("%.3f", em_finish - em_start)}s" amq-client-0.9.3/spec/regression/ 0000755 0001750 0001750 00000000000 11771004303 016167 5 ustar tfheen tfheen amq-client-0.9.3/spec/regression/bad_frame_slicing_in_adapters_spec.rb 0000644 0001750 0001750 00000003362 11771004303 025513 0 ustar tfheen tfheen # encoding: binary require 'spec_helper' require 'integration/coolio/spec_helper' require 'integration/eventmachine/spec_helper' describe "AMQ::Client::CoolioClient", :nojruby => true do include EventedSpec::SpecHelper default_timeout 1 let(:message) { "Message with xCE \xCE" } it "should receive the message with xCE byte in it without errors" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do end queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) queue.bind("amq.fanout") queue.consume(true) do |_, consumer_tag| queue.on_delivery do |method, header, payload| @received_message = payload done end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) exchange.publish(message) end end @received_message.should == message end end describe AMQ::Client::EventMachineClient do include EventedSpec::SpecHelper default_timeout 1 let(:message) { "Message with xCE \xCE" } it "should receive the message with xCE byte in it without errors" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do end queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) queue.bind("amq.fanout") queue.consume(true) do |_, consumer_tag| queue.on_delivery do |method, header, payload| @received_message = payload done end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) exchange.publish(message) end end @received_message.should == message end end amq-client-0.9.3/spec/unit/ 0000755 0001750 0001750 00000000000 11771004303 014766 5 ustar tfheen tfheen amq-client-0.9.3/spec/unit/client_spec.rb 0000644 0001750 0001750 00000003162 11771004303 017605 0 ustar tfheen tfheen # encoding: utf-8 require "ostruct" require "spec_helper" require "amq/client" describe AMQ::Client do if RUBY_PLATFORM =~ /java/ ADAPTERS = { :event_machine => "Async::EventMachineClient" } else ADAPTERS = { :event_machine => "Async::EventMachineClient", :coolio => "Async::CoolioClient" } end it "should have VERSION" do AMQ::Client::const_defined?(:VERSION).should be_true end ADAPTERS.each do |adapter_name, adapter_const_name| describe ".adapters" do before(:all) do @meta = AMQ::Client.adapters[adapter_name] end it "should provide info about path to the adapter" do require @meta[:path] end it "should provide info about const_name" do @meta[:const_name].should eql(adapter_const_name) end end end describe ".connect(settings = nil, &block)" do include EventedSpec::SpecHelper default_timeout 1 context "with specified adapter" do it "should connect using event_machine adapter" do em do AMQ::Client.connect(:adapter => :event_machine) do |client| client.class.name.should eql("AMQ::Client::Async::EventMachineClient") done end end end # it it "should connect using coolio adapter", :nojruby => true do coolio do AMQ::Client.connect(:adapter => :coolio) do |client| client.class.name.should eql("AMQ::Client::Async::CoolioClient") done end end end # it end # context "with specified adapter" end # describe .connect end # describe AMQ::Client amq-client-0.9.3/spec/unit/client/ 0000755 0001750 0001750 00000000000 11771004303 016244 5 ustar tfheen tfheen amq-client-0.9.3/spec/unit/client/mixins/ 0000755 0001750 0001750 00000000000 11771004303 017553 5 ustar tfheen tfheen amq-client-0.9.3/spec/unit/client/mixins/status_spec.rb 0000644 0001750 0001750 00000003371 11771004303 022441 0 ustar tfheen tfheen # encoding: utf-8 require "spec_helper" require "amq/client/openable" describe AMQ::Client::Openable do subject do Class.new { include AMQ::Client::Openable }.new end describe "#status=" do context "if it is in the permitted values" do it "should be able to store status" do lambda { subject.status = :opened }.should_not raise_error end end context "when given value isn't in the permitted values" do it "should raise ImproperStatusError" do lambda { subject.status = :sleepy }.should raise_error(AMQ::Client::Openable::ImproperStatusError) end end end describe "#opened?" do it "should be true if the status is :opened" do subject.status = :opened subject.should be_opened end it "should be false if the status isn't :opened" do subject.status = :opening subject.should_not be_opened end end describe "#closed?" do it "should be true if the status is :closed" do subject.status = :closed subject.should be_closed end it "should be false if the status isn't :closed" do subject.status = :closing subject.should_not be_closed end end describe "#opening?" do it "should be true if the status is :opening" do subject.status = :opening subject.should be_opening end it "should be false if the status isn't :opening" do subject.status = :opened subject.should_not be_opening end end describe "#closing?" do it "should be true if the status is :closing" do subject.status = :closing subject.should be_closing end it "should be false if the status isn't :closing" do subject.status = :opening subject.should_not be_closing end end end amq-client-0.9.3/spec/unit/client/adapter_spec.rb 0000644 0001750 0001750 00000002467 11771004303 021234 0 ustar tfheen tfheen # encoding: utf-8 require "ostruct" require "spec_helper" require "amq/client/adapter" class SampleAdapter include AMQ::Client::Adapter end describe SampleAdapter do before(:all) do load "amq/client.rb" end describe ".settings" do it "should provide some default values" do described_class.settings.should_not be_nil described_class.settings[:host].should_not be_nil end end describe ".logger" do it "should provide a default logger" do described_class.logger.should respond_to(:debug) described_class.logger.should respond_to(:info) described_class.logger.should respond_to(:error) described_class.logger.should respond_to(:fatal) end end describe ".logger=(logger)" do context "when new logger doesn't respond to all the necessary methods" do it "should raise an exception" do lambda { described_class.logger = Object.new }.should raise_error(AMQ::Client::Logging::IncompatibleLoggerError) end it "should pass if the object provides all the necessary methods" do described_class.logging = true mock = OpenStruct.new(:debug => nil, :info => nil, :error => nil, :fatal => nil) described_class.logger = mock described_class.logger.should eql(mock) end end end end amq-client-0.9.3/spec/unit/client/settings_spec.rb 0000644 0001750 0001750 00000007226 11771004303 021452 0 ustar tfheen tfheen # encoding: utf-8 require "spec_helper" require "amq/client/settings" describe AMQ::Client::Settings do describe ".default" do it "should provide some default values" do AMQ::Client::Settings.default.should_not be_nil AMQ::Client::Settings.default[:host].should_not be_nil end end describe ".configure(&block)" do it "should merge custom settings with default settings" do settings = AMQ::Client::Settings.configure(:host => "tagadab") settings[:host].should eql("tagadab") end it "should merge custom settings from AMQP URL with default settings" do settings = AMQ::Client::Settings.configure("amqp://tagadab") settings[:host].should eql("tagadab") end end describe ".parse_amqp_url(connection_string)" do context "when schema is not one of [amqp, amqps]" do it "raises ArgumentError" do expect { described_class.parse_amqp_url("http://dev.rabbitmq.com") }.to raise_error(ArgumentError, /amqp or amqps schema/) end end it "handles amqp:// URIs w/o path part" do val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com") val[:vhost].should be_nil # in this case, default / will be used val[:host].should == "dev.rabbitmq.com" val[:port].should == 5672 val[:scheme].should == "amqp" val[:ssl].should be_false end it "handles amqps:// URIs w/o path part" do val = described_class.parse_amqp_url("amqps://dev.rabbitmq.com") val[:vhost].should be_nil val[:host].should == "dev.rabbitmq.com" val[:port].should == 5671 val[:scheme].should == "amqps" val[:ssl].should be_true end context "when URI ends in a slash" do it "parses vhost as an empty string" do val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com/") val[:host].should == "dev.rabbitmq.com" val[:port].should == 5672 val[:scheme].should == "amqp" val[:ssl].should be_false val[:vhost].should == "" end end context "when URI ends in /%2Fvault" do it "parses vhost as /vault" do val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com/%2Fvault") val[:host].should == "dev.rabbitmq.com" val[:port].should == 5672 val[:scheme].should == "amqp" val[:ssl].should be_false val[:vhost].should == "/vault" end end context "when URI is amqp://dev.rabbitmq.com/a.path.without.slashes" do it "parses vhost as a.path.without.slashes" do val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com/a.path.without.slashes") val[:host].should == "dev.rabbitmq.com" val[:port].should == 5672 val[:scheme].should == "amqp" val[:ssl].should be_false val[:vhost].should == "a.path.without.slashes" end end context "when URI is amqp://dev.rabbitmq.com/a/path/with/slashes" do it "raises an ArgumentError" do lambda { described_class.parse_amqp_url("amqp://dev.rabbitmq.com/a/path/with/slashes") }.should raise_error(ArgumentError) end end context "when URI has username:password, for instance, amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal" do it "parses them out" do val = described_class.parse_amqp_url("amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal") val[:host].should == "hub.megacorp.internal" val[:port].should == 5672 val[:scheme].should == "amqp" val[:ssl].should be_false val[:user].should == "hedgehog" val[:pass].should == "t0ps3kr3t" val[:vhost].should be_nil # in this case, default / will be used end end end end amq-client-0.9.3/spec/unit/client/entity_spec.rb 0000644 0001750 0001750 00000002610 11771004303 021116 0 ustar tfheen tfheen # encoding: utf-8 require "spec_helper" require "amq/client/entity" describe AMQ::Client::Entity do let(:klazz) do Class.new do include AMQ::Client::Entity end end subject do klazz.new(Object.new) end it "should maintain an associative array of callbacks" do subject.callbacks.should be_kind_of(Hash) end describe "#has_callback?" do it "should return true if entity has at least one callback with given name" do subject.define_callback(:init, proc {}) subject.has_callback?(:init).should be_true end it "should return false if entity doesn't have callbacks with given name" do subject.has_callback?(:init).should be_false end end describe "#exec_callback" do it "executes callback for given event" do proc = Proc.new { |*args, &block| @called = true } expect { subject.define_callback(:init, proc) subject.define_callback :init do @called2 = true end }.to change(subject.callbacks, :size).from(0).to(1) subject.callbacks[:init].size.should == 2 subject.exec_callback(:init) @called.should be_true @called2.should be_true end it "should pass arguments to the callback" do f = Proc.new { |*args| args.first } subject.define_callback :init, f subject.exec_callback(:init, 1).should eql([f]) end end end amq-client-0.9.3/spec/unit/client/logging_spec.rb 0000644 0001750 0001750 00000002472 11771004303 021236 0 ustar tfheen tfheen # encoding: utf-8 require "spec_helper" class TestLogger def log(message) message end alias_method :debug, :log alias_method :info, :log alias_method :error, :log alias_method :fatal, :log end class LoggingTestClass attr_accessor :logging def client OpenStruct.new(:logger => TestLogger.new) end include AMQ::Client::Logging end describe AMQ::Client::Logging do # We have to use Kernel#load so extensions to the # Logging module from client.rb will be overridden. before(:all) do load "amq/client/logging.rb" AMQ::Client::Logging.logging = true end after(:all) do AMQ::Client::Logging.logging = false end context "including to an incompatible class" do it "should raise an NotImplementedError if the class doesn't define method client" do lambda { Class.new { include AMQ::Client::Logging } }.should raise_error(NotImplementedError) end end context "including to a compatible class" do subject { LoggingTestClass.new } it "should be able to log via #client#logger of given class" do subject.logging = true subject.debug("message").should eql("message") end it "should not log anything if subject#logging is false" do subject.logging = false subject.debug("message").should be_nil end end end amq-client-0.9.3/spec/integration/ 0000755 0001750 0001750 00000000000 11771004303 016332 5 ustar tfheen tfheen amq-client-0.9.3/spec/integration/coolio/ 0000755 0001750 0001750 00000000000 11771004303 017616 5 ustar tfheen tfheen amq-client-0.9.3/spec/integration/coolio/basic_cancel_spec.rb 0000644 0001750 0001750 00000002520 11771004303 023542 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Basic.Cancel", :nojruby => true do include EventedSpec::SpecHelper default_timeout 4 let(:messages) { (0..99).map {|i| "Message #{i}" } } it "should stop receiving messages after receiving cancel-ok" do @received_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end messages.each do |message| exchange.publish(message) end end delayed(1.5) { @received_messages.should =~ messages queue.cancel do exchange.publish("Extra message, should not be received") end } done(2.5) { @received_messages.should =~ messages } end end end # it "should stop receiving messages after receiving cancel-ok" end # describe AMQ::Client::CoolioClient, "Basic.Consume" amq-client-0.9.3/spec/integration/coolio/connection_close_spec.rb 0000644 0001750 0001750 00000001025 11771004303 024477 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Connection.Close", :nojruby => true do include EventedSpec::SpecHelper default_timeout 0.5 it "should issue a callback and close connection" do coolio do AMQ::Client::CoolioClient.connect do |connection| @connection = connection connection.should be_opened connection.disconnect do done end end end @connection.should be_closed end end amq-client-0.9.3/spec/integration/coolio/tx_rollback_spec.rb 0000644 0001750 0001750 00000002131 11771004303 023456 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Tx.Rollback", :nojruby => true do include EventedSpec::SpecHelper default_timeout 4 let(:message) { "Hello, world!" } # # Examples # it "should cancel all the changes done during transaction" do pending("Need to figure out details with AMQP protocol on that matter") received_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) do queue.bind(exchange) end channel.tx_select do done(0.1) queue.consume(true) do |method, header, message| received_messages << message unless message.nil? end exchange.publish(message) channel.tx_rollback end end end received_messages.should == [] end end amq-client-0.9.3/spec/integration/coolio/basic_ack_spec.rb 0000644 0001750 0001750 00000002324 11771004303 023055 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Basic.Ack", :nojruby => true do include EventedSpec::SpecHelper default_timeout 1 context "sending 100 messages" do let(:messages) { (0..99).map {|i| "Message #{i}" } } it "should receive & acknowledge all the messages" do @received_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") queue.consume do |_, consumer_tag| queue.on_delivery do |method, header, payload| queue.acknowledge(method.delivery_tag) @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end # consume end # open done(0.8) { @received_messages.should =~ messages } end # coolio_amqp_connect end # it end # context end # describe amq-client-0.9.3/spec/integration/coolio/tx_commit_spec.rb 0000644 0001750 0001750 00000002040 11771004303 023154 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Tx.Commit", :nojruby => true do include EventedSpec::SpecHelper default_timeout 4 let(:message) { "Hello, world!" } # # Examples # it "should confirm transaction completeness" do received_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) do queue.bind(exchange) end channel.tx_select do queue.consume(true) do |header, payload, delivery_tag, redelivered, exchange, routing_key, message_count| received_messages << message done end exchange.publish(message) channel.tx_commit end end end received_messages.should == [message] end end amq-client-0.9.3/spec/integration/coolio/channel_close_spec.rb 0000644 0001750 0001750 00000001244 11771004303 023753 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Channel.Close", :nojruby => true do include EventedSpec::SpecHelper default_timeout 1 it "should close the channel" do @events = [] coolio_amqp_connect do |client| @events << :connect channel = AMQ::Client::Channel.new(client, 1) channel.open do @events << :open channel.close do @events << :close client.disconnect do @events << :disconnect done end end end end @events.should == [:connect, :open, :close, :disconnect] end end amq-client-0.9.3/spec/integration/coolio/basic_get_spec.rb 0000644 0001750 0001750 00000004322 11771004303 023076 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Basic.Get", :nojruby => true do include EventedSpec::SpecHelper default_timeout 1 context "when set two messages beforehand" do let(:messages) { ["message 1", "message 2"] } it "synchronously fetches all the messages" do @received_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) do queue.bind("amq.fanout") exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) do puts "Published a message: #{message}" end end queue.get(true) do |method, header, payload| puts "Got #{payload}" @received_messages << payload end queue.get(true) do |method, header, payload| puts "Got #{payload}" @received_messages << payload end delayed(0.5) { # need to delete the queue manually because #get doesn't count as consumption, # hence, no auto-delete queue.delete } done(0.75) { @received_messages.should =~ messages } end end end end end context "when sent no messages beforehand" do it "should receive nils" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) queue.bind("amq.fanout") exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue.get(true) do |method, header, payload| header.should be_nil payload.should be_nil queue.delete done(0.5) end # get end end # em_amqp_connect end # it end # context end amq-client-0.9.3/spec/integration/coolio/exchange_declare_spec.rb 0000644 0001750 0001750 00000010506 11771004303 024420 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Exchange.Declare", :nojruby => true do include EventedSpec::SpecHelper default_timeout 2 let(:exchange_name) { "amq-client.testexchange.#{Time.now.to_i}" } it "should create an exchange and trigger a callback" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare do exchange.delete done(0.5) end end end end # it "should create an exchange and trigger a callback" context "options" do context "passive" do context "when set" do it "should trigger channel level error if given exchange doesn't exist" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(true, false, false, false) do @callback_fired = true end delayed(0.1) { exchange.delete } done(0.5) end end @callback_fired.should be_false @error_fired.should be_true end # it "should trigger channel level error if given exchange doesn't exist" it "should raise no error and fire the callback if given exchange exists" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(false, false, false, false) do # initial declaration AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout).declare(true) do @callback_fired = true end end delayed(0.1) { exchange.delete } done(0.5) end end @callback_fired.should be_true @error_fired.should be_false end # it "should raise no error and fire the callback if given exchange exists" end # context "when set" context "when unset" do it "should raise no error and fire the callback if given exchange doesn't exist" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(false, false, false, false) do @callback_fired = true end delayed(0.1) { exchange.delete } done(0.5) end end @callback_fired.should be_true @error_fired.should be_false end # it "should raise no error and fire the callback if given exchange doesn't exist" it "should raise no error and fire the callback if given exchange exists" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(false, false, false, false) do # initial declaration AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout).declare(false) do @callback_fired = true end end delayed(0.1) { exchange.delete } done(0.5) end end @callback_fired.should be_true @error_fired.should be_false end # it "should raise no error and fire the callback if given exchange exists" end # context "when unset" end # context "passive" # Other options make little sense to test end # context "options" end # describe amq-client-0.9.3/spec/integration/coolio/channel_flow_spec.rb 0000644 0001750 0001750 00000002230 11771004303 023611 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Channel.Flow", :nojruby => true do include EventedSpec::SpecHelper default_timeout 1 it "should control the flow of channel" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.flow_is_active?.should be_true channel.flow(false) do |_, flow_active| flow_active.should be_false channel.flow(true) do |_, flow_active| flow_active.should be_true end end done end end end it "should not raise errors when no state change occurs" do coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) expect { channel.open do channel.flow_is_active?.should be_true channel.flow(false) do |_, flow_active| flow_active.should be_false channel.flow(false) do |_, flow_active| flow_active.should be_false end end done end }.to_not raise_error end end end amq-client-0.9.3/spec/integration/coolio/connection_start_spec.rb 0000644 0001750 0001750 00000002457 11771004303 024541 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' # # We assume that default connection settings (amqp://guest:guest@localhost:5672/) should work # describe "AMQ::Client::CoolioClient", "Connection.Start", :nojruby => true do include EventedSpec::SpecHelper default_timeout 0.5 context "with valid credentials" do it "should trigger the callback" do coolio do AMQ::Client::CoolioClient.connect do |client| client.should be_opened done end end end end context "with invalid credentials" do context "when given an errback" do it "should trigger the errback" do coolio do AMQ::Client::CoolioClient.connect(:port => 12938, :on_tcp_connection_failure => proc { done }) do |client| raise "This callback should never happen" end end end end context "when given no errback" do it "should raise an error" do expect { coolio do begin AMQ::Client::CoolioClient.connect(:port => 12938) { } done rescue Exception => e done(0.5) end end }.to raise_error(AMQ::Client::TCPConnectionFailed) end end # context end # context end # describe amq-client-0.9.3/spec/integration/coolio/basic_consume_spec.rb 0000644 0001750 0001750 00000011505 11771004303 023771 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' # # Note that this spec doesn't test acknowledgements. # See basic_ack_spec for example with acks # describe "AMQ::Client::CoolioClient", "Basic.Consume", :nojruby => true do include EventedSpec::SpecHelper default_timeout 4 context "sending 100 messages" do let(:messages) { (0..99).map {|i| "Message #{i}" } } it "should receive all the messages" do @received_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end done(1.5) { @received_messages.should =~ messages } end end end # it "should receive all the messages" it "should not leave messages in the queues with noack=true" do @received_messages = [] @rereceived_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.qos(0, 1) # Maximum prefetch size = 1 queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") # Change noack to false and watch spec fail queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end # We're opening another channel and starting consuming the same queue, # assuming 1.5 secs was enough to receive all the messages delayed(1.5) do other_channel = AMQ::Client::Channel.new(client, 2) other_channel.open do other_channel.qos(0, 1) # Maximum prefetch size = 1 other_queue = AMQ::Client::Queue.new(client, other_channel, queue.name) other_queue.consume(true) do |amq_method| other_queue.on_delivery do |method, header, payload| @rereceived_messages << payload end end end end end done(2.5) { @rereceived_messages.should == [] @received_messages.should =~ messages } end end # it "should not leave messages in the queues with noack=true" end # context "sending 100 messages" end # describe AMQ::Client::CoolioClient, "Basic.Consume" describe "Multiple", AMQ::Client::Async::Consumer, :nojruby => true do include EventedSpec::SpecHelper default_timeout 4 context "sharing the same queue with equal prefetch levels" do let(:messages) { (0..99).map {|i| "Message #{i}" } } it "have messages distributed to them in the round-robin manner" do @consumer1_mailbox = [] @consumer2_mailbox = [] @consumer3_mailbox = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") consumer1 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{Time.now}") consumer2 = AMQ::Client::Async::Consumer.new(channel, queue) consumer3 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{rand}-#{Time.now}", false, true) consumer1.consume.on_delivery do |method, header, payload| @consumer1_mailbox << payload end consumer2.consume(true).on_delivery do |method, header, payload| @consumer2_mailbox << payload end consumer3.consume(false) do puts "Consumer 3 is ready" end consumer3.on_delivery do |method, header, payload| @consumer3_mailbox << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end done(1.5) { @consumer1_mailbox.size.should == 34 @consumer2_mailbox.size.should == 33 @consumer3_mailbox.size.should == 33 } end end # it end # context end # describe amq-client-0.9.3/spec/integration/coolio/spec_helper.rb 0000644 0001750 0001750 00000001333 11771004303 022434 0 ustar tfheen tfheen # encoding: utf-8 begin require "amq/client/adapters/coolio" rescue LoadError => e if RUBY_PLATFORM =~ /java/ puts "WARNING: Cool.io specs will not run on jruby" else # reraise, cause unknown raise e end end require "amq/client/queue" require "amq/client/exchange" require "evented-spec" case RUBY_VERSION when "1.8.7" then class Array alias sample choice end when /^1.9/ then Encoding.default_internal = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 end def coolio_amqp_connect(&block) coolio do AMQ::Client::CoolioClient.connect(:port => 5672, :vhost => "amq_client_testbed", :frame_max => 2**16-1, :heartbeat_interval => 1) do |client| yield client end end end amq-client-0.9.3/spec/integration/coolio/basic_return_spec.rb 0000644 0001750 0001750 00000002425 11771004303 023640 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/coolio/spec_helper' describe "AMQ::Client::CoolioClient", "Basic.Return", :nojruby => true do include EventedSpec::SpecHelper default_timeout 1.0 context "when messages are sent to a direct exchange not bound to a queue" do let(:messages) { (0..9).map {|i| "Message #{i}" } } it "should return all the messages" do @returned_messages = [] coolio_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) # need to delete the queue manually because we don't start consumption, # hence, no auto-delete delayed(0.4) { queue.delete } exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method, header, body| @returned_messages << method.reply_text end messages.each do |message| exchange.publish(message, AMQ::Protocol::EMPTY_STRING, {}, false, true) end end done(0.6) { @returned_messages.size == messages.size } end @returned_messages.should == ["NO_CONSUMERS"] * messages.size end end end amq-client-0.9.3/spec/integration/eventmachine/ 0000755 0001750 0001750 00000000000 11771004303 021000 5 ustar tfheen tfheen amq-client-0.9.3/spec/integration/eventmachine/basic_cancel_spec.rb 0000644 0001750 0001750 00000002727 11771004303 024735 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Basic.Cancel" do include EventedSpec::SpecHelper default_timeout 4 let(:messages) { (0..99).map {|i| "Message #{i}" } } it "should stop receiving messages after receiving cancel-ok" do @received_messages = [] @received_basic_cancel_ok = false em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end messages.each do |message| exchange.publish(message) end end delayed(1.5) { @received_messages.should =~ messages queue.cancel do @received_basic_cancel_ok = true exchange.publish("Extra message, should not be received") end } done(2.5) { @received_messages.should =~ messages @received_basic_cancel_ok.should be_true } end end end # it "should stop receiving messages after receiving cancel-ok" end # describe AMQ::Client::EventMachineClient, "Basic.Consume" amq-client-0.9.3/spec/integration/eventmachine/connection_close_spec.rb 0000644 0001750 0001750 00000001017 11771004303 025662 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Connection.Close" do include EventedSpec::SpecHelper default_timeout 0.5 it "should issue a callback and close connection" do em do AMQ::Client::EventMachineClient.connect do |connection| @connection = connection connection.should be_opened connection.disconnect do done end end end @connection.should be_closed end end amq-client-0.9.3/spec/integration/eventmachine/regressions/ 0000755 0001750 0001750 00000000000 11771004303 023343 5 ustar tfheen tfheen amq-client-0.9.3/spec/integration/eventmachine/regressions/amqp_gem_issue66_spec.rb 0000644 0001750 0001750 00000001034 11771004303 030052 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "handling immediate disconnection" do include EventedSpec::SpecHelper default_timeout 4 after :all do done end it "successfully disconnects" do em_amqp_connect do EventMachine.run do c = described_class.connect c.disconnect do puts "Disconnection callback has fired!" done end end end # em_amqp_connect end # it end # describe amq-client-0.9.3/spec/integration/eventmachine/tx_rollback_spec.rb 0000644 0001750 0001750 00000002125 11771004303 024643 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Tx.Rollback" do include EventedSpec::SpecHelper default_timeout 4 let(:message) { "Hello, world!" } it "should cancel all the changes done during transaction" do pending("Need to figure out details with AMQP protocol on that matter") received_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) do queue.bind(exchange) end channel.tx_select do done(0.1) queue.consume(true) do |header, payload, delivery_tag, redelivered, exchange, routing_key, message_count| received_messages << message end exchange.publish(message) channel.tx_rollback end end end received_messages.should == [] end end amq-client-0.9.3/spec/integration/eventmachine/basic_ack_spec.rb 0000644 0001750 0001750 00000002163 11771004303 024240 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Basic.Ack" do include EventedSpec::SpecHelper default_timeout 4 context "sending 100 messages" do let(:messages) { (0..99).map {|i| "Message #{i}" } } it "should receive all the messages" do @received_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") queue.consume do |amq_method| queue.on_delivery do |method, header, payload| queue.acknowledge(method.delivery_tag) @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end done(3.5) { @received_messages =~ messages } end end end end end amq-client-0.9.3/spec/integration/eventmachine/tx_commit_spec.rb 0000644 0001750 0001750 00000002122 11771004303 024337 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Tx.Commit" do # # Environment # include EventedSpec::SpecHelper default_timeout 4 let(:message) { "Hello, world!" } # # Examples # it "should confirm transaction completeness" do received_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) do queue.bind(exchange) end channel.tx_select do queue.consume(true) do |header, payload, delivery_tag, redelivered, exchange, routing_key, message_count| received_messages << message done end exchange.publish(message) channel.tx_commit end end # em_amqp_connect end received_messages.should == [message] end # it end # describe amq-client-0.9.3/spec/integration/eventmachine/channel_close_spec.rb 0000644 0001750 0001750 00000001245 11771004303 025136 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Channel.Close" do include EventedSpec::SpecHelper default_timeout 1 it "should close the channel" do @events = [] em_amqp_connect do |connection| @events << :connect channel = AMQ::Client::Channel.new(connection, 1) channel.open do @events << :open channel.close do @events << :close connection.disconnect do @events << :disconnect done end end end end @events.should == [:connect, :open, :close, :disconnect] end end amq-client-0.9.3/spec/integration/eventmachine/queue_declare_spec.rb 0000644 0001750 0001750 00000001266 11771004303 025147 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "queue.declare" do # # Environment # include EventedSpec::SpecHelper default_timeout 1 # # Examples # context "when queue name is nil" do it "raises ArgumentError" do em_amqp_connect do |connection| ch = AMQ::Client::Channel.new(connection, 1) ch.open do |ch| begin AMQ::Client::Queue.new(connection, ch, nil) rescue ArgumentError => ae ae.message.should =~ /queue name must not be nil/ done end end end end end # context end amq-client-0.9.3/spec/integration/eventmachine/basic_get_spec.rb 0000644 0001750 0001750 00000004317 11771004303 024264 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Basic.Get" do include EventedSpec::SpecHelper default_timeout 1 context "when set two messages beforehand" do let(:messages) { ["message 1", "message 2"] } it "synchronously fetches all the messages" do @received_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) do queue.bind("amq.fanout") exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) do puts "Published a message: #{message}" end end queue.get(true) do |method, header, payload| puts "Got #{payload}" @received_messages << payload end queue.get(true) do |method, header, payload| puts "Got #{payload}" @received_messages << payload end delayed(0.5) { # need to delete the queue manually because #get doesn't count as consumption, # hence, no auto-delete queue.delete } done(0.75) { @received_messages.should =~ messages } end end end end end context "when sent no messages beforehand" do it "should receive nils" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel) queue.declare(false, false, false, true) queue.bind("amq.fanout") exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) queue.get(true) do |method, header, payload| header.should be_nil payload.should be_nil queue.delete done(0.5) end # get end end # em_amqp_connect end # it end # context end # describe amq-client-0.9.3/spec/integration/eventmachine/exchange_declare_spec.rb 0000644 0001750 0001750 00000011636 11771004303 025607 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Exchange.Declare" do # # Environment # include EventedSpec::SpecHelper default_timeout 2 let(:exchange_name) { "amq-client.testexchange.#{Time.now.to_i}" } # # Examples # context "when exchange type is non-standard" do context "and DOES NOT begin with x-" do it "raises an exception" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do begin AMQ::Client::Exchange.new(client, channel, exchange_name, "my_shiny_metal_exchange_type") rescue AMQ::Client::UnknownExchangeTypeError => e done end end # channel.open end # em_amqp_connect end # it end # context end # context it "should create an exchange and trigger a callback" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, "fanout") exchange.declare do exchange.delete done(0.2) end end end end # it "should create an exchange and trigger a callback" context "options" do context "passive" do context "when set" do it "should trigger channel level error if given exchange doesn't exist" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(true, false, false, false) do @callback_fired = true end delayed(0.1) { exchange.delete } done(0.3) end end @callback_fired.should be_false @error_fired.should be_true end # it "should trigger channel level error if given exchange doesn't exist" it "should raise no error and fire the callback if given exchange exists" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(false, false, false, false) do # initial declaration AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout).declare(true) do @callback_fired = true end end delayed(0.1) { exchange.delete } done(0.3) end end @callback_fired.should be_true @error_fired.should be_false end # it "should raise no error and fire the callback if given exchange exists" end # context "when set" context "when unset" do it "should raise no error and fire the callback if given exchange doesn't exist" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(false, false, false, false) do @callback_fired = true end delayed(0.1) { exchange.delete } done(0.3) end end @callback_fired.should be_true @error_fired.should be_false end # it "should raise no error and fire the callback if given exchange doesn't exist" it "should raise no error and fire the callback if given exchange exists" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.on_error do @error_fired = true end exchange = AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout) exchange.declare(false, false, false, false) do # initial declaration AMQ::Client::Exchange.new(client, channel, exchange_name, :fanout).declare(false) do @callback_fired = true end end delayed(0.1) { exchange.delete } done(0.3) end end @callback_fired.should be_true @error_fired.should be_false end # it "should raise no error and fire the callback if given exchange exists" end # context "when unset" end # context "passive" # Other options make little sense to test end # context "options" end # describe amq-client-0.9.3/spec/integration/eventmachine/channel_flow_spec.rb 0000644 0001750 0001750 00000001610 11771004303 024774 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Channel#flow" do include EventedSpec::SpecHelper default_timeout 2 it "controls channel flow state" do em_amqp_connect do |client| flow_states = [] channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.flow_is_active?.should be_true channel.flow(false) do |flow_status1| channel.flow_is_active?.should be_false flow_states << channel.flow_is_active? channel.flow(true) do |flow_status2| channel.flow_is_active?.should be_true flow_states << channel.flow_is_active? end # channel.flow end # channel.flow end # channel.open done(1.0) { flow_states.should == [false, true] } end # em_amqp_connect end # it end # describe amq-client-0.9.3/spec/integration/eventmachine/concurrent_basic_publish_spec.rb 0000644 0001750 0001750 00000007637 11771004303 027425 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' include PlatformDetection if mri? require "multi_json" describe AMQ::Client::EventMachineClient, "Basic.Publish" do include EventedSpec::SpecHelper default_timeout 21.0 context "when messages are published across threads" do let(:inputs) do [ { :index=>{:_routing=>530,:_index=>"optimizer",:_type=>"earnings",:_id=>530}}, { :total_conversions=>0,:banked_clicks=>0,:total_earnings=>0,:pending_conversions=>0,:paid_net_earnings=>0,:banked_conversions=>0,:pending_earnings=>0,:optimizer_id=>530,:total_impressions=>0,:banked_earnings=>0,:bounce_count=>0,:time_on_page=>0,:total_clicks=>0,:entrances=>0,:pending_clicks=>0,:paid_earnings=>0}, { :index=>{:_routing=>430,:_index=>"optimizer",:_type=>"earnings",:_id=>430}}, { :total_conversions=>1443,:banked_clicks=>882,:total_earnings=>5796.3315841537,:pending_conversions=>22,:paid_net_earnings=>4116.90224486802,:banked_conversions=>1086,:pending_earnings=>257.502767857143,:optimizer_id=>430,:total_impressions=>6370497,:banked_earnings=>122.139339285714,:bounce_count=>6825,:time_on_page=>0,:total_clicks=>38143,:entrances=>12336,:pending_clicks=>1528,:paid_earnings=>5670.78224486798}, { :index=>{:_routing=>506,:_index=>"optimizer",:_type=>"earnings",:_id=>506}}, { :total_conversions=>237,:banked_clicks=>232,:total_earnings=>550.6212071428588277,:pending_conversions=>9,:paid_net_earnings=>388.021207142857,:banked_conversions=>225,:pending_earnings=>150.91,:optimizer_id=>506,:total_impressions=>348319,:banked_earnings=>12.92,:bounce_count=>905,:time_on_page=>0,:total_clicks=>4854,:entrances=>1614,:pending_clicks=>1034,:paid_earnings=>537.501207142858}, {:index=>{:_routing=>345,:_index=>"optimizer",:_type=>"earnings",:_id=>345}}, {:total_conversions=>0,:banked_clicks=>0,:total_earnings=>0,:pending_conversions=>0,:paid_net_earnings=>0,:banked_conversions=>0,:pending_earnings=>0,:optimizer_id=>345,:total_impressions=>0,:banked_earnings=>0,:bounce_count=>0,:time_on_page=>0,:total_clicks=>0,:entrances=>0,:pending_clicks=>0,:paid_earnings=>0} ] end let(:messages) { inputs.map {|i| MultiJson.encode(i) } * 3 } # the purpose of this is to make sure UNEXPECTED_FRAME issues are gone it "synchronizes on channel" do @received_messages = [] @received_messages = [] em_amqp_connect do |client| client.on_error do |conn, connection_close| fail "Handling a connection-level exception: #{connection_close.reply_text}" end channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) EventMachine.add_timer(2.0) do # ZOMG THREADS! 30.times do Thread.new do messages.each do |message| exchange.publish(message, queue.name, {}, false, true) end end end end end # let it run for several seconds because you know, concurrency issues do not always manifest themselves # immediately. MK. done(14.0) { # we don't care about the exact number, just the fact that there are # no UNEXPECTED_FRAME connection-level exceptions. MK. @received_messages.size.should > 120 } end end # em_amqp_connect end # it end # context end # describe end amq-client-0.9.3/spec/integration/eventmachine/connection_start_spec.rb 0000644 0001750 0001750 00000002222 11771004303 025711 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' # # We assume that default connection settings (amqp://guest:guest@localhost:5672/) should work # describe AMQ::Client::EventMachineClient, "Connection.Start" do include EventedSpec::SpecHelper default_timeout 0.5 context "with valid credentials" do it "should trigger the callback" do em do AMQ::Client::EventMachineClient.connect do |client| done end end end end context "with invalid credentials" do context "when given an errback" do it "should trigger the errback" do em do AMQ::Client::EventMachineClient.connect(:port => 12938, :on_tcp_connection_failure => proc { done }) do |client| raise "This callback should never happen" end end end end context "when given no errback" do it "should raise an error" do expect { em do AMQ::Client::EventMachineClient.connect(:port => 12938) { } done(0.5) end }.to raise_error(AMQ::Client::TCPConnectionFailed) end end end end amq-client-0.9.3/spec/integration/eventmachine/basic_consume_spec.rb 0000644 0001750 0001750 00000012770 11771004303 025160 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' # # Note that this spec doesn't test acknowledgements. # See basic_ack_spec for example with acks # describe AMQ::Client::EventMachineClient, "AMQP consumer" do include EventedSpec::SpecHelper default_timeout 5 context "sending 100 messages" do let(:messages) { (0..99).map {|i| "Message #{i}" } } it "should receive all the messages" do @received_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end done(3.5) { @received_messages.should =~ messages } end end end # it "should receive all the messages" it "should not leave messages in the queues with noack=true" do @received_messages = [] @rereceived_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do channel.qos(0, 1) # Maximum prefetch size = 1 queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") # Change noack to false and watch spec fail queue.consume(true) do |amq_method| queue.on_delivery do |method, header, payload| @received_messages << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end # We're opening another channel and starting consuming the same queue, # assuming 2.0 secs was enough to receive all the messages delayed(2.0) do other_channel = AMQ::Client::Channel.new(client, 2) other_channel.open do other_channel.qos(0, 1) # Maximum prefetch size = 1 other_queue = AMQ::Client::Queue.new(client, other_channel, queue.name) other_queue.consume(true) do |amq_method| other_queue.on_delivery do |method, header, payload| @rereceived_messages << payload end end end end end done(4.5) { @rereceived_messages.should == [] @received_messages.should =~ messages } end end # it "should not leave messages in the queues with noack=true" end # context "sending 100 messages" end # describe AMQ::Client::EventMachineClient, "Basic.Consume" describe "Multiple", AMQ::Client::Async::Consumer do include EventedSpec::SpecHelper default_timeout 4 context "sharing the same queue with equal prefetch levels" do let(:messages) { (0..99).map {|i| "Message #{i}" } } it "have messages distributed to them in the round-robin manner" do @consumer1_mailbox = [] @consumer2_mailbox = [] @consumer3_mailbox = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") consumer1 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{Time.now}") consumer2 = AMQ::Client::Async::Consumer.new(channel, queue) consumer3 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{rand}-#{Time.now}", false, true) consumer1.consume.on_delivery do |method, header, payload| @consumer1_mailbox << payload end consumer2.consume(true).on_delivery do |method, header, payload| @consumer2_mailbox << payload end consumer3.consume(false) do puts "Consumer 3 is ready" end consumer3.on_delivery do |method, header, payload| @consumer3_mailbox << payload end exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout) messages.each do |message| exchange.publish(message) end end done(1.5) { @consumer1_mailbox.size.should == 34 @consumer2_mailbox.size.should == 33 @consumer3_mailbox.size.should == 33 } end end # it end # context end # describe describe AMQ::Client::Async::Consumer do include EventedSpec::SpecHelper default_timeout 4 context "registered with a callback" do it "runs that callback when basic.consume-ok arrives" do em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) queue.bind("amq.fanout") consumer1 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{Time.now}") consumer1.consume do done end # consume do end # open do end # em_amqp_connect end # it end # context end # describe amq-client-0.9.3/spec/integration/eventmachine/spec_helper.rb 0000644 0001750 0001750 00000001061 11771004303 023614 0 ustar tfheen tfheen # encoding: utf-8 require "amq/client/adapters/event_machine" require "amq/client/queue" require "amq/client/exchange" require "evented-spec" case RUBY_VERSION when "1.8.7" then class Array alias sample choice end when /^1.9/ then Encoding.default_internal = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 end def em_amqp_connect(&block) em do AMQ::Client::EventMachineClient.connect(:port => 5672, :vhost => "amq_client_testbed", :frame_max => 65536, :heartbeat_interval => 1) do |client| yield client end end end amq-client-0.9.3/spec/integration/eventmachine/basic_return_spec.rb 0000644 0001750 0001750 00000002432 11771004303 025020 0 ustar tfheen tfheen # encoding: utf-8 require 'spec_helper' require 'integration/eventmachine/spec_helper' describe AMQ::Client::EventMachineClient, "Basic.Return" do include EventedSpec::SpecHelper default_timeout 1.0 context "when messages are sent to a direct exchange not bound to a queue" do let(:messages) { (0..9).map {|i| "Message #{i}" } } it "should return all the messages" do @returned_messages = [] em_amqp_connect do |client| channel = AMQ::Client::Channel.new(client, 1) channel.open do queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true) # need to delete the queue manually because we don't start consumption, # hence, no auto-delete delayed(0.4) { queue.delete } exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method, header, body| @returned_messages << method.reply_text end messages.each do |message| exchange.publish(message, AMQ::Protocol::EMPTY_STRING, {}, false, true) end end done(0.6) { @returned_messages.size == messages.size } end @returned_messages.should == ["NO_CONSUMERS"] * messages.size end end end amq-client-0.9.3/spec/spec_helper.rb 0000644 0001750 0001750 00000001101 11771004303 016616 0 ustar tfheen tfheen # encoding: utf-8 require "bundler" Bundler.setup Bundler.require(:default, :test) require 'amq/client' # # Ruby version-specific # require "effin_utf8" case RUBY_VERSION when "1.8.7" then class Array alias sample choice end when /^1.9/ then Encoding.default_internal = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 end RSpec.configure do |c| c.filter_run_excluding :nojruby => true if RUBY_PLATFORM =~ /java/ end module PlatformDetection def mri? !defined?(RUBY_ENGINE) || (defined?(RUBY_ENGINE) && ("ruby" == RUBY_ENGINE)) end end amq-client-0.9.3/spec/client/ 0000755 0001750 0001750 00000000000 11771004303 015265 5 ustar tfheen tfheen amq-client-0.9.3/spec/client/framing/ 0000755 0001750 0001750 00000000000 11771004303 016710 5 ustar tfheen tfheen amq-client-0.9.3/spec/client/framing/string_frame_spec.rb 0000644 0001750 0001750 00000003272 11771004303 022733 0 ustar tfheen tfheen # encoding: utf-8 require "spec_helper" # We need to require AMQ-Protocol manually. # In the library this is required in the file # amq/client.rb, but this is a unit test and # we don't want to mess around with unecessary # dependencies. require "amq/protocol/client" require "amq/protocol/frame" # We have to use Kernel#load so extensions to the # Logging module from client.rb will be overridden. load "amq/client/framing/string/frame.rb" describe AMQ::Client::Framing::String do subject do AMQ::Client::Framing::String::Frame end # Created by: # frame = AMQ::Protocol::Queue::Declare.encode(1, "tasks", false, false, false, false, {}) # frame.encode # frame.payload before do data = ["\x01\x00\x00\x00\x00\x00\b"] data << "\x00\n\x00(\x01/\x00\x00" data << "\xCE" @string = data.join subject.stub(:decode_header).with(data.first).and_return([1, 0, data[1].bytesize]) end it "should be able to decode frame type" do subject.decode(@string).should be_kind_of(AMQ::Protocol::MethodFrame) end it "should be able to decode channel" do subject.decode(@string).channel.should eql(0) end it "should be able to decode payload" do subject.decode(@string).payload.should eql("\x00\n\x00(\x01/\x00\x00") end it "should raise an error if the frame length is miscalculated" do data = @string[0..-2] + "too long" + "\xCE" string = String.new(data) lambda { subject.decode(string) }.should raise_error(AMQ::Client::BadLengthError) end it "should raise an error if the frame doesn't end with FINAL_OCTET" do string = @string[0..-2] + "x" lambda { subject.decode(string) }.should raise_error(AMQ::Client::NoFinalOctetError) end end amq-client-0.9.3/spec/client/framing/io_frame_spec.rb 0000644 0001750 0001750 00000003155 11771004303 022034 0 ustar tfheen tfheen # encoding: binary require "spec_helper" require "stringio" # We need to require AMQ-Protocol manually. # In the library this is required in the file # amq/client.rb, but this is a unit test and # we don't want to mess around with unecessary # dependencies. require "amq/protocol/client" require "amq/protocol/frame" # We have to use Kernel#load so extensions to the # Logging module from client.rb will be overridden. load "amq/client/framing/io/frame.rb" describe AMQ::Client::Framing::IO do subject do AMQ::Client::Framing::IO::Frame end # Created by: # frame = AMQ::Protocol::Queue::Declare.encode(1, "tasks", false, false, false, false, {}) # frame.encode # frame.payload before do data = ["\x01\x00\x00\x00\x00\x00\b"] data << "\x00\n\x00(\x01/\x00\x00" data << "\xCE" @io = StringIO.new(data.join) subject.stub(:decode_header).with(data.first).and_return([1, 0, data[1].bytesize]) end it "should be able to decode frame type" do subject.decode(@io).should be_kind_of(AMQ::Protocol::MethodFrame) end it "should be able to decode channel" do subject.decode(@io).channel.should eql(0) end it "should be able to decode payload" do subject.decode(@io).payload.should eql("\x00\n\x00(\x01/\x00\x00") end context "if the frame length is miscalculated" do it "should raise an error" end context "if frame doesn't end with FINAL_OCTET" do it "should raise an error" do data = @io.read[0..-2] + "too long" + "\xCE" io = StringIO.new(data) lambda { subject.decode(io) }.should raise_error(AMQ::Client::NoFinalOctetError) end end end amq-client-0.9.3/spec/client/protocol/ 0000755 0001750 0001750 00000000000 11771004303 017126 5 ustar tfheen tfheen amq-client-0.9.3/spec/client/protocol/get_response_spec.rb 0000644 0001750 0001750 00000003550 11771004303 023165 0 ustar tfheen tfheen # encoding: utf-8 require "spec_helper" require "amq/protocol/client" require "amq/protocol/get_response" # require "amq/protocol/frame" # # # We have to use Kernel#load so extensions to the # # Logging module from client.rb will be overridden. # load "amq/client/framing/string/frame.rb" describe AMQ::Protocol::GetResponse do describe "when method is GetOk" do before { @method = AMQ::Protocol::Basic::GetOk.new("dtag", true, "tasks", "foo", 1) } subject { AMQ::Protocol::GetResponse.new(@method) } it "should NOT be #empty?" do should_not be_empty end it "should have #delivery_tag" do subject.delivery_tag.should eql("dtag") end it "should have #redelivered" do subject.redelivered.should be_true end it "should have #exchange" do subject.exchange.should eql("tasks") end it "should have #routing_key" do subject.routing_key.should eql("foo") end it "should have #message_count" do subject.message_count.should eql(1) end it "should NOT have #cluster_id" do subject.cluster_id.should be_nil end end describe "when method is GetEmpty" do before { @method = AMQ::Protocol::Basic::GetEmpty.new("ID") } subject { AMQ::Protocol::GetResponse.new(@method) } it "should be #empty?" do should be_empty end it "should NOT have #delivery_tag" do subject.delivery_tag.should be_nil end it "should NOT have #redelivered" do subject.redelivered.should be_nil end it "should NOT have #exchange" do subject.exchange.should be_nil end it "should NOT have #routing_key" do subject.routing_key.should be_nil end it "should NOT have #message_count" do subject.message_count.should be_nil end it "should have #cluster_id" do subject.cluster_id.should eql("ID") end end end amq-client-0.9.3/.gitmodules 0000644 0001750 0001750 00000000504 11771004303 015231 0 ustar tfheen tfheen [submodule "vendor/amq-protocol"] path = vendor/amq-protocol url = https://github.com/ruby-amqp/amq-protocol.git [submodule "vendor/cool.io"] path = vendor/cool.io url = https://github.com/tarcieri/cool.io.git [submodule "vendor/evented-spec"] path = vendor/evented-spec url = git://github.com/markiz/evented-spec.git amq-client-0.9.3/metadata.yml 0000644 0001750 0001750 00000022706 11771004303 015367 0 ustar tfheen tfheen --- !ruby/object:Gem::Specification name: amq-client version: !ruby/object:Gem::Version hash: 61 prerelease: segments: - 0 - 9 - 3 version: 0.9.3 platform: ruby authors: - Jakub Stastny - Michael S. Klishin - Theo Hultberg - Mark Abramov autorequire: bindir: bin cert_chain: [] date: 2012-06-22 00:00:00 Z dependencies: - !ruby/object:Gem::Dependency name: eventmachine prerelease: false requirement: &id001 !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version hash: 3 segments: - 0 version: "0" type: :runtime version_requirements: *id001 - !ruby/object:Gem::Dependency name: amq-protocol prerelease: false requirement: &id002 !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version hash: 57 segments: - 0 - 9 - 1 version: 0.9.1 type: :runtime version_requirements: *id002 description: amq-client is a fully-featured, low-level AMQP 0.9.1 client with pluggable networking I/O adapters (EventMachine, cool.io, Eventpanda and so on) and supposed to back more opinionated AMQP clients (such as amqp gem) or be used directly in cases when access to more advanced AMQP 0.9.1 features is more important that convenient APIs email: - stastny@101ideas.cz - michael@novemberain.com executables: [] extensions: [] extra_rdoc_files: - README.textile files: - .gitignore - .gitmodules - .rspec - .travis.yml - .yardopts - Gemfile - LICENSE - README.textile - amq-client.gemspec - bin/ci/before_build.sh - bin/set_test_suite_realms_up.sh - examples/coolio_adapter/basic_consume.rb - examples/coolio_adapter/basic_consume_with_acknowledgements.rb - examples/coolio_adapter/basic_consume_with_rejections.rb - examples/coolio_adapter/basic_publish.rb - examples/coolio_adapter/channel_close.rb - examples/coolio_adapter/example_helper.rb - examples/coolio_adapter/exchange_declare.rb - examples/coolio_adapter/kitchen_sink1.rb - examples/coolio_adapter/queue_bind.rb - examples/coolio_adapter/queue_purge.rb - examples/coolio_adapter/queue_unbind.rb - examples/eventmachine_adapter/authentication/connection_open_failure_due_to_invalid_vhost.rb - examples/eventmachine_adapter/authentication/plain_password_with_custom_role_credentials.rb - examples/eventmachine_adapter/authentication/plain_password_with_default_role_credentials.rb - examples/eventmachine_adapter/authentication/plain_password_with_incorrect_credentials_handled_with_a_callback.rb - examples/eventmachine_adapter/authentication/plain_password_with_incorrect_credentials_handled_with_a_rescue_block.rb - examples/eventmachine_adapter/basic_cancel.rb - examples/eventmachine_adapter/basic_consume.rb - examples/eventmachine_adapter/basic_consume_with_acknowledgements.rb - examples/eventmachine_adapter/basic_consume_with_rejections.rb - examples/eventmachine_adapter/basic_get.rb - examples/eventmachine_adapter/basic_get_with_empty_queue.rb - examples/eventmachine_adapter/basic_publish.rb - examples/eventmachine_adapter/basic_qos.rb - examples/eventmachine_adapter/basic_recover.rb - examples/eventmachine_adapter/basic_return.rb - examples/eventmachine_adapter/channel_close.rb - examples/eventmachine_adapter/channel_flow.rb - examples/eventmachine_adapter/channel_level_exception_handling.rb - examples/eventmachine_adapter/error_handling/connection_failure_callback.rb - examples/eventmachine_adapter/error_handling/connection_failure_exception.rb - examples/eventmachine_adapter/error_handling/connection_loss_handler_that_fails_over.rb - examples/eventmachine_adapter/error_handling/connection_loss_handler_with_automatic_recovery.rb - examples/eventmachine_adapter/error_handling/connection_loss_handler_with_manual_recovery.rb - examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb - examples/eventmachine_adapter/example_helper.rb - examples/eventmachine_adapter/exchange_declare.rb - examples/eventmachine_adapter/extensions/rabbitmq/handling_confirm_select_ok.rb - examples/eventmachine_adapter/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb - examples/eventmachine_adapter/extensions/rabbitmq/publisher_confirmations_with_unroutable_message.rb - examples/eventmachine_adapter/kitchen_sink1.rb - examples/eventmachine_adapter/queue_bind.rb - examples/eventmachine_adapter/queue_declare.rb - examples/eventmachine_adapter/queue_purge.rb - examples/eventmachine_adapter/queue_unbind.rb - examples/eventmachine_adapter/server_capabilities.rb - examples/eventmachine_adapter/tls/tls_without_peer_verification.rb - examples/eventmachine_adapter/tx_commit.rb - examples/eventmachine_adapter/tx_rollback.rb - examples/eventmachine_adapter/tx_select.rb - examples/tls_certificates/client/cert.pem - examples/tls_certificates/client/key.pem - examples/tls_certificates/client/keycert.p12 - examples/tls_certificates/client/req.pem - examples/tls_certificates/server/cert.pem - examples/tls_certificates/server/key.pem - examples/tls_certificates/server/keycert.p12 - examples/tls_certificates/server/req.pem - examples/tls_certificates/testca/cacert.cer - examples/tls_certificates/testca/cacert.pem - examples/tls_certificates/testca/certs/01.pem - examples/tls_certificates/testca/certs/02.pem - examples/tls_certificates/testca/index.txt - examples/tls_certificates/testca/index.txt.attr - examples/tls_certificates/testca/index.txt.attr.old - examples/tls_certificates/testca/index.txt.old - examples/tls_certificates/testca/openssl.cnf - examples/tls_certificates/testca/private/cakey.pem - examples/tls_certificates/testca/serial - examples/tls_certificates/testca/serial.old - irb.rb - lib/amq/client.rb - lib/amq/client/adapter.rb - lib/amq/client/adapters/coolio.rb - lib/amq/client/adapters/event_machine.rb - lib/amq/client/async/adapter.rb - lib/amq/client/async/adapters/coolio.rb - lib/amq/client/async/adapters/event_machine.rb - lib/amq/client/async/adapters/eventmachine.rb - lib/amq/client/async/callbacks.rb - lib/amq/client/async/channel.rb - lib/amq/client/async/consumer.rb - lib/amq/client/async/entity.rb - lib/amq/client/async/exchange.rb - lib/amq/client/async/extensions/rabbitmq/basic.rb - lib/amq/client/async/extensions/rabbitmq/confirm.rb - lib/amq/client/async/queue.rb - lib/amq/client/callbacks.rb - lib/amq/client/channel.rb - lib/amq/client/consumer_tag_generator.rb - lib/amq/client/entity.rb - lib/amq/client/exceptions.rb - lib/amq/client/exchange.rb - lib/amq/client/extensions/rabbitmq.rb - lib/amq/client/extensions/rabbitmq/basic.rb - lib/amq/client/extensions/rabbitmq/confirm.rb - lib/amq/client/framing/io/frame.rb - lib/amq/client/framing/string/frame.rb - lib/amq/client/handlers_registry.rb - lib/amq/client/logging.rb - lib/amq/client/openable.rb - lib/amq/client/queue.rb - lib/amq/client/server_named_entity.rb - lib/amq/client/settings.rb - lib/amq/client/version.rb - lib/amq/protocol/get_response.rb - spec/benchmarks/adapters.rb - spec/client/framing/io_frame_spec.rb - spec/client/framing/string_frame_spec.rb - spec/client/protocol/get_response_spec.rb - spec/integration/coolio/basic_ack_spec.rb - spec/integration/coolio/basic_cancel_spec.rb - spec/integration/coolio/basic_consume_spec.rb - spec/integration/coolio/basic_get_spec.rb - spec/integration/coolio/basic_return_spec.rb - spec/integration/coolio/channel_close_spec.rb - spec/integration/coolio/channel_flow_spec.rb - spec/integration/coolio/connection_close_spec.rb - spec/integration/coolio/connection_start_spec.rb - spec/integration/coolio/exchange_declare_spec.rb - spec/integration/coolio/spec_helper.rb - spec/integration/coolio/tx_commit_spec.rb - spec/integration/coolio/tx_rollback_spec.rb - spec/integration/eventmachine/basic_ack_spec.rb - spec/integration/eventmachine/basic_cancel_spec.rb - spec/integration/eventmachine/basic_consume_spec.rb - spec/integration/eventmachine/basic_get_spec.rb - spec/integration/eventmachine/basic_return_spec.rb - spec/integration/eventmachine/channel_close_spec.rb - spec/integration/eventmachine/channel_flow_spec.rb - spec/integration/eventmachine/concurrent_basic_publish_spec.rb - spec/integration/eventmachine/connection_close_spec.rb - spec/integration/eventmachine/connection_start_spec.rb - spec/integration/eventmachine/exchange_declare_spec.rb - spec/integration/eventmachine/queue_declare_spec.rb - spec/integration/eventmachine/regressions/amqp_gem_issue66_spec.rb - spec/integration/eventmachine/spec_helper.rb - spec/integration/eventmachine/tx_commit_spec.rb - spec/integration/eventmachine/tx_rollback_spec.rb - spec/regression/bad_frame_slicing_in_adapters_spec.rb - spec/spec_helper.rb - spec/unit/client/adapter_spec.rb - spec/unit/client/entity_spec.rb - spec/unit/client/logging_spec.rb - spec/unit/client/mixins/status_spec.rb - spec/unit/client/settings_spec.rb - spec/unit/client_spec.rb - tasks.rb homepage: http://github.com/ruby-amqp/amq-client licenses: [] post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version hash: 3 segments: - 0 version: "0" required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version hash: 3 segments: - 0 version: "0" requirements: [] rubyforge_project: amq-client rubygems_version: 1.8.15 signing_key: specification_version: 3 summary: amq-client is a fully-featured, low-level AMQP 0.9.1 client test_files: [] has_rdoc: amq-client-0.9.3/LICENSE 0000644 0001750 0001750 00000002062 11771004303 014062 0 ustar tfheen tfheen Copyright (c) 2011 Jakub Šťastný aka Botanicus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. amq-client-0.9.3/.rspec 0000644 0001750 0001750 00000000011 11771004303 014162 0 ustar tfheen tfheen --colour amq-client-0.9.3/.yardopts 0000644 0001750 0001750 00000000050 11771004303 014716 0 ustar tfheen tfheen --no-private --protected lib/amq/**/*.rb amq-client-0.9.3/tasks.rb 0000755 0001750 0001750 00000000325 11771004303 014532 0 ustar tfheen tfheen #!/usr/bin/env nake # encoding: utf-8 if RUBY_VERSION =~ /^1.9/ Encoding.default_internal = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 end require "contributors" load "contributors.nake" amq-client-0.9.3/examples/ 0000755 0001750 0001750 00000000000 11771004303 014673 5 ustar tfheen tfheen amq-client-0.9.3/examples/tls_certificates/ 0000755 0001750 0001750 00000000000 11771004303 020222 5 ustar tfheen tfheen amq-client-0.9.3/examples/tls_certificates/server/ 0000755 0001750 0001750 00000000000 11771004303 021530 5 ustar tfheen tfheen amq-client-0.9.3/examples/tls_certificates/server/req.pem 0000644 0001750 0001750 00000001623 11771004303 023024 0 ustar tfheen tfheen -----BEGIN CERTIFICATE REQUEST----- MIICbDCCAVQCAQAwJzEUMBIGA1UEAxMLZ2lvdmUubG9jYWwxDzANBgNVBAoTBnNl cnZlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN0ESmeX4FFwjNng zqkHrj1xP9hTF5tN6RSrQeEVcBNtrjheRLHzU2fl0xWcqAmAlVGEHFTRmkG3j/Ci Apppgjj84ASBtRwfTc6cRcc0sHnzp4kZ1oUeRJA5+dRsEjOlAqVCMYt+OafqZeQt bmUs/k6s36em4Qjhar+OBshBCn23srCD49v1V0kbDR2YyVV88/wVUJGkYH2UlzUD LDyAoeDiaL+7IooV0tX0hZ/4NeW9FDa+WOZASFKrhu/GcK2binkHsAUd59OeV1KA ZFRm7Ijn/i8UzKkHd15X6WS73nnXi40XSCDrp4MB+g2MSZxrT0/4YHLwt8my6IF4 VXiKu2MCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4IBAQC2aRbyq5pJ34M8jsaEjcks iov5KP17jfnHnz517/rKxKYRaoxftXVvUbtDLKMQNMAA9K65jetg6/6zqi3QTJwd 52Pn6OYTpzyFov42KRh1OSiRRa5CNXzDlHhosuVnVEOo2rdQggWZTY1clAbjEJmU N6bn6NSL4B/Vn8GAVxXhRGGoHj26LupdoI6GS2S3xuExw0xiS3usq6xYthpxHQ/L pQI2Ijk+IJZPnJR2RZji/7P3nWHWQX+HrCagCu4oyY4o7inWPVJpxD+1LmagRhv5 RyMdQKoY+6x3/r+tWATTNOVqbGzfuKj6TQSkCYvOZOejlRBsMhyYlpldVMCRmaoh -----END CERTIFICATE REQUEST----- amq-client-0.9.3/examples/tls_certificates/server/key.pem 0000644 0001750 0001750 00000003217 11771004303 023026 0 ustar tfheen tfheen -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA3QRKZ5fgUXCM2eDOqQeuPXE/2FMXm03pFKtB4RVwE22uOF5E sfNTZ+XTFZyoCYCVUYQcVNGaQbeP8KICmmmCOPzgBIG1HB9NzpxFxzSwefOniRnW hR5EkDn51GwSM6UCpUIxi345p+pl5C1uZSz+Tqzfp6bhCOFqv44GyEEKfbeysIPj 2/VXSRsNHZjJVXzz/BVQkaRgfZSXNQMsPICh4OJov7siihXS1fSFn/g15b0UNr5Y 5kBIUquG78ZwrZuKeQewBR3n055XUoBkVGbsiOf+LxTMqQd3XlfpZLveedeLjRdI IOungwH6DYxJnGtPT/hgcvC3ybLogXhVeIq7YwIDAQABAoIBAEu0+YussZET/Ztw bznlQKEZVuZR6Ccxs+J5m1JvlnmBO4lheSR/lhVj2z9u7vx6SCupFk9TkQRrzWl/ BWdBNvMwY8gHajNc4bkhPKG1AbJ0bPIAoMPuj0vcICDMeBuqrVJQb0o6DaPgHdDg Yw1TMTVf8CiseC8jj/5XtykHZoGTNTKzusvTjL8hTXFaWQfHQaN3WC1qwrFU2+x6 AJeoSz5F1Q/lykqVAdl2B1L39kiSCAkbVE1GI2qjftCff3ycufYV/fxXeyZwZx9B NGWUJFyZte8EcrAUoo9B/gvALGDbJsSUsbri+HsRsdOQT3K/giafUipX2FB8Bnxm nasEfskCgYEA74PrKYo13mTUWRJ2FQTBRHLsMR53PK83RpRRs8361/uCJrjpqfdD 2fUt8kH0rmm2vaWYsllucJoYdYSC9CQdECLzpOZS907PJHXCOsFsBjw74fvjZ+gY 9EXIENZSOSR1PQCWZm+5lL4xi/T+beWBfz0YksErj2GM7dyJeQjkIz8CgYEA7Dpx ANgrgO9WTu51NIlKt3P7+t6q6MHQcWuzkWMBmVU4zxeyggux+ucMj+l3KLyw7fLT jRz03eGpqjQT8Yl676uYONhTDC9VOBbLgjShuVOX7lleMLxVFJWqL1FphNghxysF HVCq1WH0Qu4keirPEotBxkNZRaRYHwRYlVPKMt0CgYEApIHSAj0IlNBiPS995R/X 8sCQU4heU1LxP0vd9gZy1OfNU/VLoE7RzqEkxrDgcu7u8cEMaOsd/L8KL6UtIKyx PYUUHV2I/I2nnp43Io35OSsj4ipU3eg/Q3+uU0oxPUg6MgT2SDNSnsQnWb6TBj5N PGxlNV7yIU/aMQF5dqVRtJcCgYEArC4Mn6jwTJImPnHgS+Kl6wFG8JvLxss9uu3d fGLFj5VmSsvi+Ja9qzstFNf+WlruOwF64KfycqdAmyZKQwsJ6BcSZJyIK6F0Y+V5 f/YMyp/7ZWcOGEetW8uat9KHLqS6OglJOQzK96zl9MLPI5yAQevujSwZrYEUGcd5 KZ5hCqECgYBExYSDJOuSMvKFw66jrLiBedLPuzh1iznwd6e4idpqIUkdhbEuXhHG +35HeN5cGwjbjXtIjxJsAddTbjvSqaPukmBKLm1ABqF3r0irbNaPcK1xfG9a5L28 /enwipaSWjGovfDXWqmmCvWC8M7iGiqFChI87WlzbvaAapOW0D576Q== -----END RSA PRIVATE KEY----- amq-client-0.9.3/examples/tls_certificates/server/cert.pem 0000644 0001750 0001750 00000002046 11771004303 023172 0 ustar tfheen tfheen -----BEGIN CERTIFICATE----- MIIC5DCCAcygAwIBAgIBATANBgkqhkiG9w0BAQUFADATMREwDwYDVQQDEwhNeVRl c3RDQTAeFw0xMTA0MTcyMDE3MjdaFw0xMjA0MTYyMDE3MjdaMCcxFDASBgNVBAMT C2dpb3ZlLmxvY2FsMQ8wDQYDVQQKEwZzZXJ2ZXIwggEiMA0GCSqGSIb3DQEBAQUA A4IBDwAwggEKAoIBAQDdBEpnl+BRcIzZ4M6pB649cT/YUxebTekUq0HhFXATba44 XkSx81Nn5dMVnKgJgJVRhBxU0ZpBt4/wogKaaYI4/OAEgbUcH03OnEXHNLB586eJ GdaFHkSQOfnUbBIzpQKlQjGLfjmn6mXkLW5lLP5OrN+npuEI4Wq/jgbIQQp9t7Kw g+Pb9VdJGw0dmMlVfPP8FVCRpGB9lJc1Ayw8gKHg4mi/uyKKFdLV9IWf+DXlvRQ2 vljmQEhSq4bvxnCtm4p5B7AFHefTnldSgGRUZuyI5/4vFMypB3deV+lku95514uN F0gg66eDAfoNjEmca09P+GBy8LfJsuiBeFV4irtjAgMBAAGjLzAtMAkGA1UdEwQC MAAwCwYDVR0PBAQDAgUgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEB BQUAA4IBAQCCmvsAQ1GaPfoKMqCWxyrQ2BNVPWm9J65thZKxZQF01gLox9cpv6+X QERcD71HStxbzh2B8Hebbk9OplGuyrdgfvzUxcn88kObj6udipDx4YxTJvtff/9w xeD5OWDVgef0GkB1Rjj3C3W/sfmTZBYfdKuWuwxMG/NxISkQP4aFHwJnPrzNx9ON bHoKVNrQ2iKAiMysjnFeA/4QuhBQRf41h9SBWwJEW3Ts91TzbgcjCL46Dq29QB9A 4v8t6K/nibP6n53zHbVzdxIEJ2hFKm+vuqaHRW3048Xgww1xkdxrVbyGp9si92i1 KJ5SDIOR8bQ7OXvdvpiyy6p9fIG0Z6w0 -----END CERTIFICATE----- amq-client-0.9.3/examples/tls_certificates/server/keycert.p12 0000644 0001750 0001750 00000004455 11771004303 023532 0 ustar tfheen tfheen 0 )0 *H 00 *H 0| 0u *H 0 *H 0 HvޱFº t>ɒnSl]6=˰p}wRZcf+\_7@cV4FdOE6\Dn!{%4Tha 9qX<`!YFGe.i*1\$dڄh t&OVtL?Z:oK$1Y,5 <hMF[?H|#/K U2C&z)ofPB#~YF,T!#\({s2`̙!忌zAql";+_8aˢw[Q[g_ecu9b IrӚ ﶠxpLk٢=n>G7{ZL,|QOlfAO^gn^zrF7Aq SBpQ ] f#hJ2rB4&A CZ>ϒc\~^0,@*cc?BRB6`֔v[VK'Nk&N4zLZ ԧ5rBr̽S\#Zelf]ИXkQ߁M89dg4b|j0q kME g&E=.6QB`e#9*ΘLIgD`4*Md|K]2Ƒ 4w