amqp 0.8.0.rc13 → 0.8.0.rc14
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -1
- data/.travis.yml +8 -2
- data/.yardopts +1 -0
- data/CHANGELOG +9 -0
- data/Gemfile +17 -11
- data/README.md +26 -16
- data/amqp.gemspec +2 -2
- data/bin/ci/before_build.sh +21 -0
- data/docs/08Migration.textile +199 -5
- data/docs/AMQP091ModelExplained.textile +322 -0
- data/docs/Bindings.textile +24 -4
- data/docs/Clustering.textile +1 -1
- data/docs/ConnectingToTheBroker.textile +98 -82
- data/docs/ConnectionEncryptionWithTLS.textile +65 -5
- data/docs/DocumentationGuidesIndex.textile +93 -13
- data/docs/Durability.textile +1 -1
- data/docs/ErrorHandling.textile +458 -94
- data/docs/Exchanges.textile +901 -87
- data/docs/GettingStarted.textile +278 -143
- data/docs/PatternsAndUseCases.textile +420 -0
- data/docs/Queues.textile +730 -178
- data/docs/RabbitMQVersions.textile +18 -3
- data/docs/RunningTests.textile +1 -1
- data/docs/TestingWithEventedSpec.textile +121 -0
- data/docs/Troubleshooting.textile +15 -1
- data/docs/VendorSpecificExtensions.textile +1 -1
- data/docs/diagrams/001_hello_world_example_routing.png +0 -0
- data/docs/diagrams/002_blabbr_example_routing.png +0 -0
- data/docs/diagrams/003_weathr_example_routing.png +0 -0
- data/docs/diagrams/004_fanout_exchange.png +0 -0
- data/docs/diagrams/005_direct_exchange.png +0 -0
- data/docs/diagrams/redhat/direct_exchange.png +0 -0
- data/docs/diagrams/redhat/fanout_exchange.png +0 -0
- data/docs/diagrams/redhat/topic_exchange.png +0 -0
- data/examples/error_handling/automatic_recovery_of_channel_and_queues.rb +50 -0
- data/examples/error_handling/automatically_recovering_hello_world_consumer.rb +51 -0
- data/examples/error_handling/automatically_recovering_hello_world_consumer_that_uses_a_server_named_queue.rb +51 -0
- data/examples/error_handling/basic_connection_failover.rb +22 -0
- data/examples/error_handling/channel_level_exception.rb +9 -2
- data/examples/error_handling/connection_level_exception.rb +8 -1
- data/examples/error_handling/connection_level_exception_with_objects.rb +49 -0
- data/examples/error_handling/connection_loss_handler.rb +1 -5
- data/examples/error_handling/hello_world_producer.rb +43 -0
- data/examples/error_handling/insufficient_permissions.rb +54 -0
- data/examples/error_handling/manual_connection_and_channel_recovery.rb +71 -0
- data/examples/error_handling/queue_exclusivity_violation.rb +41 -0
- data/examples/error_handling/queue_name_violation.rb +31 -0
- data/examples/exchanges/autodeletion_of_exchanges.rb +1 -4
- data/examples/guides/queues/01a_declaring_a_server_named_queue_using_queue_constructor.rb +7 -8
- data/examples/guides/queues/01b_declaring_a_queue_using_queue_constructor.rb +7 -8
- data/examples/guides/queues/02a_declaring_a_durable_shared_queue.rb +5 -8
- data/examples/guides/queues/02b_declaring_a_durable_shared_queue.rb +5 -8
- data/examples/guides/queues/03a_declaring_a_temporary_exclusive_queue.rb +7 -8
- data/examples/guides/queues/04_bind_a_queue_using_exchange_instance.rb +9 -10
- data/examples/guides/queues/05_bind_a_queue_using_exchange_name.rb +8 -10
- data/examples/guides/queues/06_subscribe_to_receive_messages.rb +10 -12
- data/examples/guides/queues/07_fetch_a_message_from_the_queue.rb +14 -14
- data/examples/guides/queues/08_unsubscribing_a_consumer.rb +13 -16
- data/examples/guides/queues/09_unbinding_from_exchange.rb +16 -22
- data/examples/guides/queues/10_purge_a_queue.rb +13 -18
- data/examples/guides/queues/11_deleting_a_queue.rb +14 -19
- data/examples/guides/queues/12_objects_that_consume_messages.rb +69 -0
- data/examples/guides/queues/13_objects_that_consume_messages_take_two.rb +89 -0
- data/examples/hello_world.rb +1 -3
- data/examples/hello_world_with_an_empty_string.rb +5 -6
- data/examples/inspecting_server_information.rb +45 -0
- data/examples/issues/issue_93.rb +23 -0
- data/examples/issues/issue_94.rb +23 -0
- data/examples/patterns/command/consumer.rb +45 -0
- data/examples/patterns/command/producer.rb +26 -0
- data/examples/patterns/request_reply/client.rb +29 -0
- data/examples/patterns/request_reply/server.rb +26 -0
- data/examples/publishing/publishing_a_one_off_message.rb +6 -4
- data/examples/publishing/returned_messages.rb +2 -10
- data/examples/queues/accessing_message_metadata.rb +15 -13
- data/examples/queues/queue_status.rb +12 -15
- data/examples/routing/fanout_routing.rb +33 -0
- data/examples/routing/headers_routing.rb +17 -15
- data/examples/routing/round_robin_with_direct_exchange.rb +39 -0
- data/examples/routing/round_robin_with_the_default_exchange.rb +38 -0
- data/examples/routing/unroutable_mandatory_message_is_returned.rb +33 -0
- data/examples/routing/weather_updates.rb +15 -20
- data/examples/tls/using_tls.rb +41 -0
- data/lib/amqp/bit_set.rb +80 -0
- data/lib/amqp/broker.rb +72 -0
- data/lib/amqp/channel.rb +93 -13
- data/lib/amqp/client.rb +11 -22
- data/lib/amqp/compatibility/ruby187_patchlevel_check.rb +2 -0
- data/lib/amqp/connection.rb +2 -3
- data/lib/amqp/consumer.rb +208 -0
- data/lib/amqp/deprecated/fork.rb +2 -0
- data/lib/amqp/deprecated/mq.rb +2 -0
- data/lib/amqp/exchange.rb +6 -4
- data/lib/amqp/extensions/rabbitmq.rb +3 -1
- data/lib/amqp/header.rb +76 -14
- data/lib/amqp/int_allocator.rb +96 -0
- data/lib/amqp/logger.rb +2 -0
- data/lib/amqp/queue.rb +242 -86
- data/lib/amqp/rpc.rb +2 -0
- data/lib/amqp/session.rb +169 -9
- data/lib/amqp/utilities/event_loop_helper.rb +2 -0
- data/lib/amqp/utilities/server_type.rb +2 -0
- data/lib/amqp/version.rb +2 -2
- data/lib/mq.rb +4 -2
- data/lib/mq/logger.rb +3 -1
- data/lib/mq/rpc.rb +3 -1
- data/spec/integration/authentication_spec.rb +17 -10
- data/spec/integration/automatic_binding_for_default_direct_exchange_spec.rb +1 -1
- data/spec/integration/automatic_recovery_predicate_spec.rb +68 -0
- data/spec/integration/basic_get_spec.rb +2 -1
- data/spec/integration/{extensions/basic_return_spec.rb → basic_return_spec.rb} +2 -1
- data/spec/integration/channel_level_exception_handling_spec.rb +53 -0
- data/spec/integration/connection_level_exception_handling_spec.rb +49 -0
- data/spec/integration/declare_and_immediately_bind_a_server_named_queue_spec.rb +38 -17
- data/spec/integration/declare_one_hundred_server_named_queues_spec.rb +44 -0
- data/spec/integration/direct_exchange_routing_spec.rb +125 -0
- data/spec/integration/exchange_declaration_spec.rb +75 -46
- data/spec/integration/extensions/rabbitmq/publisher_confirmations_spec.rb +180 -0
- data/spec/integration/{workload_distribution_spec.rb → fanout_exchange_routing_spec.rb} +10 -9
- data/spec/integration/headers_exchange_routing_spec.rb +269 -0
- data/spec/integration/hello_world_spec.rb +77 -0
- data/spec/integration/immediate_messages_spec.rb +59 -0
- data/spec/integration/mandatory_messages_spec.rb +52 -0
- data/spec/integration/message_metadata_access_spec.rb +106 -0
- data/spec/integration/multiple_consumers_per_queue_spec.rb +319 -0
- data/spec/integration/ordering_of_published_messages_spec.rb +96 -0
- data/spec/integration/queue_declaration_spec.rb +8 -8
- data/spec/integration/queue_status_spec.rb +66 -0
- data/spec/integration/recovery/per_channel_automatic_recovery_on_graceful_broker_shutdown_spec.rb +76 -0
- data/spec/integration/recovery/per_channel_automatic_recovery_spec.rb +72 -0
- data/spec/integration/redelivery_of_unacknowledged_messages_spec.rb +96 -0
- data/spec/integration/regressions/concurrent_publishing_on_the_same_channel_spec.rb +91 -0
- data/spec/integration/regressions/empty_message_body_spec.rb +56 -0
- data/spec/integration/regressions/issue66_spec.rb +2 -1
- data/spec/integration/reply_queue_communication_spec.rb +2 -1
- data/spec/integration/store_and_forward_spec.rb +4 -3
- data/spec/integration/topic_subscription_spec.rb +2 -1
- data/spec/integration/tx_commit_spec.rb +124 -0
- data/spec/integration/tx_rollback_spec.rb +167 -0
- data/spec/spec_helper.rb +44 -71
- data/spec/unit/amqp/bit_set_spec.rb +127 -0
- data/spec/unit/amqp/channel_id_allocation_spec.rb +40 -0
- data/spec/unit/amqp/connection_spec.rb +4 -2
- data/spec/unit/amqp/int_allocator_spec.rb +116 -0
- metadata +92 -26
- data/CONTRIBUTORS +0 -29
- data/docs/Routing.textile +0 -30
- data/examples/real-world/task-queue/README.textile +0 -3
- data/examples/real-world/task-queue/consumer.rb +0 -27
- data/examples/real-world/task-queue/producer.rb +0 -22
- data/spec/unit/amqp/basic_spec.rb +0 -39
- data/tasks.rb +0 -4
data/spec/spec_helper.rb
CHANGED
@@ -1,78 +1,16 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
4
4
|
|
5
5
|
require 'bundler'
|
6
|
-
Bundler.setup
|
7
|
-
Bundler.require :default, :test
|
6
|
+
Bundler.setup(:default, :test)
|
8
7
|
|
9
8
|
require "amqp"
|
10
9
|
require "evented-spec"
|
10
|
+
require "effin_utf8"
|
11
|
+
require "multi_json"
|
11
12
|
|
12
|
-
#
|
13
|
-
RSpec::Core::Example.send(:include, Module.new {
|
14
|
-
def self.included(base)
|
15
|
-
base.class_eval do
|
16
|
-
alias_method :__finish__, :finish
|
17
|
-
remove_method :finish
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_reader :not_implemented_error
|
22
|
-
def from_not_implemented_error?
|
23
|
-
!! @not_implemented_error
|
24
|
-
end
|
25
|
-
|
26
|
-
def finish(reporter)
|
27
|
-
if @exception.is_a?(NotImplementedError)
|
28
|
-
@not_implemented_error = @exception
|
29
|
-
message = "#{@exception.message} (from #{@exception.backtrace[0]})"
|
30
|
-
self.metadata[:pending] = true
|
31
|
-
@pending_declared_in_example = message
|
32
|
-
@exception = nil
|
33
|
-
end
|
34
|
-
|
35
|
-
__finish__(reporter)
|
36
|
-
end
|
37
|
-
})
|
38
|
-
|
39
|
-
RSpec::Core::Formatters::BaseTextFormatter.send(:include, Module.new {
|
40
|
-
def self.included(base)
|
41
|
-
base.class_eval do
|
42
|
-
remove_method :dump_pending
|
43
|
-
remove_method :dump_backtrace
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def dump_pending
|
48
|
-
unless pending_examples.empty?
|
49
|
-
output.puts
|
50
|
-
output.puts "Pending:"
|
51
|
-
pending_examples.each do |pending_example|
|
52
|
-
output.puts yellow(" #{pending_example.full_description}")
|
53
|
-
output.puts grey(" # #{pending_example.execution_result[:pending_message]}")
|
54
|
-
output.puts grey(" # #{format_caller(pending_example.location)}")
|
55
|
-
if pending_example.from_not_implemented_error? && RSpec.configuration.backtrace_clean_patterns.empty?
|
56
|
-
dump_backtrace(pending_example, pending_example.not_implemented_error.backtrace)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def dump_backtrace(example, backtrace = example.execution_result[:exception].backtrace)
|
63
|
-
format_backtrace(backtrace, example).each do |backtrace_info|
|
64
|
-
output.puts grey("#{long_padding}# #{backtrace_info}")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
})
|
68
|
-
|
69
|
-
def em_amqp_connect(&block)
|
70
|
-
em do
|
71
|
-
AMQ::Client::EventMachineClient.connect(:port => 5672, :vhost => "/amq_client_testbed", :frame_max => 65536, :heartbeat_interval => 1) do |client|
|
72
|
-
yield client
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
13
|
+
puts "Using Ruby #{RUBY_VERSION}, amq-client #{AMQ::Client::VERSION} and amq-protocol #{AMQ::Protocol::VERSION}"
|
76
14
|
|
77
15
|
|
78
16
|
amqp_config = File.dirname(__FILE__) + '/amqp.yml'
|
@@ -93,7 +31,7 @@ else
|
|
93
31
|
AMQP_OPTS = {:host => 'localhost', :port => 5672}
|
94
32
|
end
|
95
33
|
|
96
|
-
puts "AMQP_OPTS = #{AMQP_OPTS.inspect}"
|
34
|
+
# puts "AMQP_OPTS = #{AMQP_OPTS.inspect}"
|
97
35
|
|
98
36
|
#
|
99
37
|
# Ruby version-specific
|
@@ -106,7 +44,42 @@ when "1.8.7" then
|
|
106
44
|
end
|
107
45
|
when "1.8.6" then
|
108
46
|
raise "Ruby 1.8.6 is not supported. Sorry, pal. Time to move on beyond One True Ruby. Yes, time flies by."
|
109
|
-
when /^1.9/ then
|
110
|
-
Encoding.default_internal = Encoding::UTF_8
|
111
|
-
Encoding.default_external = Encoding::UTF_8
|
112
47
|
end
|
48
|
+
|
49
|
+
|
50
|
+
EventMachine.kqueue = true if EventMachine.kqueue?
|
51
|
+
EventMachine.epoll = true if EventMachine.epoll?
|
52
|
+
|
53
|
+
|
54
|
+
module RabbitMQ
|
55
|
+
module Control
|
56
|
+
def rabbitmq_pid
|
57
|
+
$1.to_i if `rabbitmqctl status` =~ /\{pid,(\d+)\}/
|
58
|
+
end
|
59
|
+
|
60
|
+
def start_rabbitmq(delay = 1.0)
|
61
|
+
# this is Homebrew-specific :(
|
62
|
+
`rabbitmq-server > /dev/null 2>&1 &`; sleep(delay)
|
63
|
+
end
|
64
|
+
|
65
|
+
def stop_rabbitmq(pid = rabbitmq_pid, delay = 1.0)
|
66
|
+
`rabbitmqctl stop`; sleep(delay)
|
67
|
+
end
|
68
|
+
|
69
|
+
def kill_rabbitmq(pid = rabbitmq_pid, delay = 1.0)
|
70
|
+
# tango is down, tango is down!
|
71
|
+
Process.kill("KILL", pid); sleep(delay)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
module PlatformDetection
|
78
|
+
def mri?
|
79
|
+
!defined?(RUBY_ENGINE) || (defined?(RUBY_ENGINE) && ("ruby" == RUBY_ENGINE))
|
80
|
+
end
|
81
|
+
|
82
|
+
def rubinius?
|
83
|
+
defined?(RUBY_ENGINE) && (RUBY_ENGINE == 'rbx')
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require "amqp/bit_set"
|
6
|
+
|
7
|
+
|
8
|
+
describe AMQP::BitSet do
|
9
|
+
|
10
|
+
#
|
11
|
+
# Environment
|
12
|
+
#
|
13
|
+
|
14
|
+
let(:nbits) { (1 << 16) - 1 }
|
15
|
+
|
16
|
+
|
17
|
+
#
|
18
|
+
# Examples
|
19
|
+
#
|
20
|
+
|
21
|
+
describe "#get, #[]" do
|
22
|
+
describe "when bit at given position is set" do
|
23
|
+
subject do
|
24
|
+
o = described_class.new(nbits)
|
25
|
+
o.set(3)
|
26
|
+
o
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns true" do
|
30
|
+
subject.get(3).should be_true
|
31
|
+
end # it
|
32
|
+
end # describe
|
33
|
+
|
34
|
+
describe "when bit at given position is off" do
|
35
|
+
subject do
|
36
|
+
described_class.new(nbits)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns false" do
|
40
|
+
subject.get(5).should be_false
|
41
|
+
end # it
|
42
|
+
end # describe
|
43
|
+
end # describe
|
44
|
+
|
45
|
+
|
46
|
+
describe "#set" do
|
47
|
+
describe "when bit at given position is set" do
|
48
|
+
subject do
|
49
|
+
described_class.new(nbits)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "has no effect" do
|
53
|
+
subject.set(3)
|
54
|
+
subject.get(3).should be_true
|
55
|
+
subject.set(3)
|
56
|
+
subject[3].should be_true
|
57
|
+
end # it
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "when bit at given position is off" do
|
61
|
+
subject do
|
62
|
+
described_class.new(nbits)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "sets that bit" do
|
66
|
+
subject.set(3)
|
67
|
+
subject.get(3).should be_true
|
68
|
+
|
69
|
+
subject.set(33)
|
70
|
+
subject.get(33).should be_true
|
71
|
+
|
72
|
+
subject.set(3387)
|
73
|
+
subject.get(3387).should be_true
|
74
|
+
end
|
75
|
+
end # describe
|
76
|
+
end # describe
|
77
|
+
|
78
|
+
|
79
|
+
describe "#unset" do
|
80
|
+
describe "when bit at a given position is set" do
|
81
|
+
subject do
|
82
|
+
described_class.new(nbits)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "unsets that bit" do
|
86
|
+
subject.set(3)
|
87
|
+
subject.get(3).should be_true
|
88
|
+
subject.unset(3)
|
89
|
+
subject.get(3).should be_false
|
90
|
+
end # it
|
91
|
+
end # describe
|
92
|
+
|
93
|
+
|
94
|
+
describe "when bit at a given position is off" do
|
95
|
+
subject do
|
96
|
+
described_class.new(nbits)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "has no effect" do
|
100
|
+
subject.get(3).should be_false
|
101
|
+
subject.unset(3)
|
102
|
+
subject.get(3).should be_false
|
103
|
+
end # it
|
104
|
+
end # describe
|
105
|
+
end # describe
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
describe "#clear" do
|
110
|
+
subject do
|
111
|
+
described_class.new(nbits)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "clears all bits" do
|
115
|
+
subject.set(3)
|
116
|
+
subject.get(3).should be_true
|
117
|
+
|
118
|
+
subject.set(7668)
|
119
|
+
subject.get(7668).should be_true
|
120
|
+
|
121
|
+
subject.clear
|
122
|
+
|
123
|
+
subject.get(3).should be_false
|
124
|
+
subject.get(7668).should be_false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe AMQP::Channel do
|
6
|
+
describe ".next_channel_id" do
|
7
|
+
before :all do
|
8
|
+
described_class.reset_channel_id_allocator
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when there is a channel id available for allocation" do
|
12
|
+
it "returns that channel id" do
|
13
|
+
1024.times { described_class.next_channel_id }
|
14
|
+
|
15
|
+
described_class.next_channel_id.should == 1025
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when THERE IS NOT channel id available for allocation" do
|
20
|
+
it "raises an exception"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
describe ".release_channel_id" do
|
27
|
+
before :all do
|
28
|
+
described_class.reset_channel_id_allocator
|
29
|
+
end
|
30
|
+
|
31
|
+
it "releases that channel id" do
|
32
|
+
1024.times { described_class.next_channel_id }
|
33
|
+
described_class.next_channel_id.should == 1025
|
34
|
+
|
35
|
+
described_class.release_channel_id(128)
|
36
|
+
described_class.next_channel_id.should == 128
|
37
|
+
described_class.next_channel_id.should == 1026
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'amqp'
|
3
5
|
|
@@ -70,7 +72,7 @@ describe AMQP, 'class object' do
|
|
70
72
|
|
71
73
|
AMQP.connection.should be_connected
|
72
74
|
end
|
73
|
-
done(0.
|
75
|
+
done(0.3) { @block_fired.should be_true }
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
@@ -90,7 +92,7 @@ describe AMQP, 'class object' do
|
|
90
92
|
@block_fired_times = 0
|
91
93
|
AMQP.start(AMQP_OPTS) { @block_fired_times += 1 }
|
92
94
|
delayed(0.1) { AMQP.start(AMQP_OPTS) { @block_fired_times += 1 } }
|
93
|
-
done(0.
|
95
|
+
done(0.3) { @block_fired_times.should == 1 }
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end # .start
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require "amqp/int_allocator"
|
5
|
+
|
6
|
+
describe AMQP::IntAllocator do
|
7
|
+
|
8
|
+
#
|
9
|
+
# Environment
|
10
|
+
#
|
11
|
+
|
12
|
+
subject do
|
13
|
+
described_class.new(1, 5)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# ...
|
18
|
+
|
19
|
+
|
20
|
+
#
|
21
|
+
# Examples
|
22
|
+
#
|
23
|
+
|
24
|
+
describe "#number_of_bits" do
|
25
|
+
it "returns number of bits available for allocation" do
|
26
|
+
subject.number_of_bits.should == 4
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
describe "#hi" do
|
32
|
+
it "returns upper bound of the allocation range" do
|
33
|
+
subject.hi.should == 5
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#lo" do
|
38
|
+
it "returns lower bound of the allocation range" do
|
39
|
+
subject.lo.should == 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
describe "#allocate" do
|
45
|
+
context "when integer in the range is available" do
|
46
|
+
it "returns allocated integer" do
|
47
|
+
subject.allocate.should == 1
|
48
|
+
subject.allocate.should == 2
|
49
|
+
subject.allocate.should == 3
|
50
|
+
subject.allocate.should == 4
|
51
|
+
|
52
|
+
subject.allocate.should == -1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when integer in the range IS NOT available" do
|
57
|
+
it "returns -1" do
|
58
|
+
4.times { subject.allocate }
|
59
|
+
|
60
|
+
subject.allocate.should == -1
|
61
|
+
subject.allocate.should == -1
|
62
|
+
subject.allocate.should == -1
|
63
|
+
subject.allocate.should == -1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
describe "#free" do
|
70
|
+
context "when the integer WAS allocated" do
|
71
|
+
it "returns frees that integer" do
|
72
|
+
4.times { subject.allocate }
|
73
|
+
subject.allocate.should == -1
|
74
|
+
|
75
|
+
subject.free(1)
|
76
|
+
subject.allocate.should == 1
|
77
|
+
subject.allocate.should == -1
|
78
|
+
subject.free(2)
|
79
|
+
subject.allocate.should == 2
|
80
|
+
subject.allocate.should == -1
|
81
|
+
subject.free(3)
|
82
|
+
subject.allocate.should == 3
|
83
|
+
subject.allocate.should == -1
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when the integer WAS NOT allocated" do
|
88
|
+
it "has no effect" do
|
89
|
+
32.times { subject.free(1) }
|
90
|
+
subject.allocate.should == 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
describe "#allocated?" do
|
97
|
+
context "when given position WAS allocated" do
|
98
|
+
it "returns true" do
|
99
|
+
3.times { subject.allocate }
|
100
|
+
|
101
|
+
subject.allocated?(1).should be_true
|
102
|
+
subject.allocated?(2).should be_true
|
103
|
+
subject.allocated?(3).should be_true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when given position WAS NOT allocated" do
|
108
|
+
it "returns false" do
|
109
|
+
2.times { subject.allocate }
|
110
|
+
|
111
|
+
subject.allocated?(3).should be_false
|
112
|
+
subject.allocated?(4).should be_false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424137
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 0.8.0.
|
11
|
+
- 14
|
12
|
+
version: 0.8.0.rc14
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Aman Gupta
|
@@ -19,7 +19,8 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2011-
|
22
|
+
date: 2011-07-25 00:00:00 +04:00
|
23
|
+
default_executable:
|
23
24
|
dependencies:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: eventmachine
|
@@ -43,14 +44,12 @@ dependencies:
|
|
43
44
|
requirements:
|
44
45
|
- - ">="
|
45
46
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
47
|
+
hash: 63
|
47
48
|
segments:
|
48
49
|
- 0
|
49
|
-
-
|
50
|
+
- 8
|
50
51
|
- 0
|
51
|
-
|
52
|
-
- 34
|
53
|
-
version: 0.7.0.alpha34
|
52
|
+
version: 0.8.0
|
54
53
|
type: :runtime
|
55
54
|
version_requirements: *id002
|
56
55
|
- !ruby/object:Gem::Dependency
|
@@ -61,14 +60,12 @@ dependencies:
|
|
61
60
|
requirements:
|
62
61
|
- - ">="
|
63
62
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
63
|
+
hash: 63
|
65
64
|
segments:
|
66
65
|
- 0
|
67
|
-
-
|
66
|
+
- 8
|
68
67
|
- 0
|
69
|
-
|
70
|
-
- 6
|
71
|
-
version: 0.7.0.alpha6
|
68
|
+
version: 0.8.0
|
72
69
|
type: :runtime
|
73
70
|
version_requirements: *id003
|
74
71
|
description: Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries included.
|
@@ -82,6 +79,7 @@ extensions: []
|
|
82
79
|
extra_rdoc_files:
|
83
80
|
- README.md
|
84
81
|
- docs/08Migration.textile
|
82
|
+
- docs/AMQP091ModelExplained.textile
|
85
83
|
- docs/Bindings.textile
|
86
84
|
- docs/Clustering.textile
|
87
85
|
- docs/ConnectingToTheBroker.textile
|
@@ -91,10 +89,11 @@ extra_rdoc_files:
|
|
91
89
|
- docs/ErrorHandling.textile
|
92
90
|
- docs/Exchanges.textile
|
93
91
|
- docs/GettingStarted.textile
|
92
|
+
- docs/PatternsAndUseCases.textile
|
94
93
|
- docs/Queues.textile
|
95
94
|
- docs/RabbitMQVersions.textile
|
96
|
-
- docs/Routing.textile
|
97
95
|
- docs/RunningTests.textile
|
96
|
+
- docs/TestingWithEventedSpec.textile
|
98
97
|
- docs/Troubleshooting.textile
|
99
98
|
- docs/VendorSpecificExtensions.textile
|
100
99
|
files:
|
@@ -103,15 +102,16 @@ files:
|
|
103
102
|
- .travis.yml
|
104
103
|
- .yardopts
|
105
104
|
- CHANGELOG
|
106
|
-
- CONTRIBUTORS
|
107
105
|
- Gemfile
|
108
106
|
- README.md
|
109
107
|
- Rakefile
|
110
108
|
- amqp.gemspec
|
109
|
+
- bin/ci/before_build.sh
|
111
110
|
- bin/cleanify.rb
|
112
111
|
- bin/irb
|
113
112
|
- bin/set_test_suite_realms_up.sh
|
114
113
|
- docs/08Migration.textile
|
114
|
+
- docs/AMQP091ModelExplained.textile
|
115
115
|
- docs/Bindings.textile
|
116
116
|
- docs/Clustering.textile
|
117
117
|
- docs/ConnectingToTheBroker.textile
|
@@ -121,12 +121,21 @@ files:
|
|
121
121
|
- docs/ErrorHandling.textile
|
122
122
|
- docs/Exchanges.textile
|
123
123
|
- docs/GettingStarted.textile
|
124
|
+
- docs/PatternsAndUseCases.textile
|
124
125
|
- docs/Queues.textile
|
125
126
|
- docs/RabbitMQVersions.textile
|
126
|
-
- docs/Routing.textile
|
127
127
|
- docs/RunningTests.textile
|
128
|
+
- docs/TestingWithEventedSpec.textile
|
128
129
|
- docs/Troubleshooting.textile
|
129
130
|
- docs/VendorSpecificExtensions.textile
|
131
|
+
- docs/diagrams/001_hello_world_example_routing.png
|
132
|
+
- docs/diagrams/002_blabbr_example_routing.png
|
133
|
+
- docs/diagrams/003_weathr_example_routing.png
|
134
|
+
- docs/diagrams/004_fanout_exchange.png
|
135
|
+
- docs/diagrams/005_direct_exchange.png
|
136
|
+
- docs/diagrams/redhat/direct_exchange.png
|
137
|
+
- docs/diagrams/redhat/fanout_exchange.png
|
138
|
+
- docs/diagrams/redhat/topic_exchange.png
|
130
139
|
- examples/channels/open_channel_with_one_arity_callback.rb
|
131
140
|
- examples/channels/open_channel_without_assignment.rb
|
132
141
|
- examples/channels/prefetch_as_constructor_argument.rb
|
@@ -134,14 +143,24 @@ files:
|
|
134
143
|
- examples/channels/qos_aka_prefetch_without_callback.rb
|
135
144
|
- examples/connection/connect_and_immediately_disconnect.rb
|
136
145
|
- examples/deprecated/default_thread_local_channel_instance.rb
|
146
|
+
- examples/error_handling/automatic_recovery_of_channel_and_queues.rb
|
147
|
+
- examples/error_handling/automatically_recovering_hello_world_consumer.rb
|
148
|
+
- examples/error_handling/automatically_recovering_hello_world_consumer_that_uses_a_server_named_queue.rb
|
149
|
+
- examples/error_handling/basic_connection_failover.rb
|
137
150
|
- examples/error_handling/channel_level_exception.rb
|
138
151
|
- examples/error_handling/channel_level_exception_with_multiple_channels_involved.rb
|
139
152
|
- examples/error_handling/connection_level_exception.rb
|
153
|
+
- examples/error_handling/connection_level_exception_with_objects.rb
|
140
154
|
- examples/error_handling/connection_loss_handler.rb
|
141
155
|
- examples/error_handling/global_channel_level_exception_handler.rb
|
142
156
|
- examples/error_handling/handling_authentication_failure_with_a_callback.rb
|
143
157
|
- examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
|
144
158
|
- examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
|
159
|
+
- examples/error_handling/hello_world_producer.rb
|
160
|
+
- examples/error_handling/insufficient_permissions.rb
|
161
|
+
- examples/error_handling/manual_connection_and_channel_recovery.rb
|
162
|
+
- examples/error_handling/queue_exclusivity_violation.rb
|
163
|
+
- examples/error_handling/queue_name_violation.rb
|
145
164
|
- examples/error_handling/tcp_connection_failure_handling_with_a_rescue_block.rb
|
146
165
|
- examples/error_handling/tcp_connection_failure_with_a_callback.rb
|
147
166
|
- examples/exchanges/autodeletion_of_exchanges.rb
|
@@ -166,15 +185,20 @@ files:
|
|
166
185
|
- examples/guides/queues/09_unbinding_from_exchange.rb
|
167
186
|
- examples/guides/queues/10_purge_a_queue.rb
|
168
187
|
- examples/guides/queues/11_deleting_a_queue.rb
|
188
|
+
- examples/guides/queues/12_objects_that_consume_messages.rb
|
189
|
+
- examples/guides/queues/13_objects_that_consume_messages_take_two.rb
|
169
190
|
- examples/hello_world.rb
|
170
191
|
- examples/hello_world_with_an_empty_string.rb
|
171
192
|
- examples/hello_world_with_eventmachine_in_a_separate_thread.rb
|
172
193
|
- examples/hello_world_with_large_payload.rb
|
194
|
+
- examples/inspecting_server_information.rb
|
173
195
|
- examples/issues/amq_client_issue_7.rb
|
174
196
|
- examples/issues/amq_protocol_issue_14.rb
|
175
197
|
- examples/issues/issue_75.rb
|
176
198
|
- examples/issues/issue_79.rb
|
177
199
|
- examples/issues/issue_80.rb
|
200
|
+
- examples/issues/issue_93.rb
|
201
|
+
- examples/issues/issue_94.rb
|
178
202
|
- examples/legacy/ack.rb
|
179
203
|
- examples/legacy/callbacks.rb
|
180
204
|
- examples/legacy/clock.rb
|
@@ -185,6 +209,10 @@ files:
|
|
185
209
|
- examples/legacy/primes-simple.rb
|
186
210
|
- examples/legacy/primes.rb
|
187
211
|
- examples/legacy/stocks.rb
|
212
|
+
- examples/patterns/command/consumer.rb
|
213
|
+
- examples/patterns/command/producer.rb
|
214
|
+
- examples/patterns/request_reply/client.rb
|
215
|
+
- examples/patterns/request_reply/server.rb
|
188
216
|
- examples/publishing/publishing_a_one_off_message.rb
|
189
217
|
- examples/publishing/publishing_callback.rb
|
190
218
|
- examples/publishing/returned_messages.rb
|
@@ -198,12 +226,14 @@ files:
|
|
198
226
|
- examples/queues/rejecting_messages_without_requeueuing.rb
|
199
227
|
- examples/queues/using_explicit_acknowledgements.rb
|
200
228
|
- examples/rack/publish_a_message_on_request/thin.ru
|
201
|
-
- examples/
|
202
|
-
- examples/real-world/task-queue/consumer.rb
|
203
|
-
- examples/real-world/task-queue/producer.rb
|
229
|
+
- examples/routing/fanout_routing.rb
|
204
230
|
- examples/routing/headers_routing.rb
|
205
231
|
- examples/routing/pubsub.rb
|
232
|
+
- examples/routing/round_robin_with_direct_exchange.rb
|
233
|
+
- examples/routing/round_robin_with_the_default_exchange.rb
|
234
|
+
- examples/routing/unroutable_mandatory_message_is_returned.rb
|
206
235
|
- examples/routing/weather_updates.rb
|
236
|
+
- examples/tls/using_tls.rb
|
207
237
|
- examples/tls_certificates/client/cert.pem
|
208
238
|
- examples/tls_certificates/client/key.pem
|
209
239
|
- examples/tls_certificates/client/keycert.p12
|
@@ -225,10 +255,13 @@ files:
|
|
225
255
|
- examples/tls_certificates/testca/serial
|
226
256
|
- examples/tls_certificates/testca/serial.old
|
227
257
|
- lib/amqp.rb
|
258
|
+
- lib/amqp/bit_set.rb
|
259
|
+
- lib/amqp/broker.rb
|
228
260
|
- lib/amqp/channel.rb
|
229
261
|
- lib/amqp/client.rb
|
230
262
|
- lib/amqp/compatibility/ruby187_patchlevel_check.rb
|
231
263
|
- lib/amqp/connection.rb
|
264
|
+
- lib/amqp/consumer.rb
|
232
265
|
- lib/amqp/deprecated/fork.rb
|
233
266
|
- lib/amqp/deprecated/logger.rb
|
234
267
|
- lib/amqp/deprecated/mq.rb
|
@@ -239,6 +272,7 @@ files:
|
|
239
272
|
- lib/amqp/ext/emfork.rb
|
240
273
|
- lib/amqp/extensions/rabbitmq.rb
|
241
274
|
- lib/amqp/header.rb
|
275
|
+
- lib/amqp/int_allocator.rb
|
242
276
|
- lib/amqp/logger.rb
|
243
277
|
- lib/amqp/queue.rb
|
244
278
|
- lib/amqp/rpc.rb
|
@@ -251,29 +285,61 @@ files:
|
|
251
285
|
- lib/mq/rpc.rb
|
252
286
|
- spec/integration/authentication_spec.rb
|
253
287
|
- spec/integration/automatic_binding_for_default_direct_exchange_spec.rb
|
288
|
+
- spec/integration/automatic_recovery_predicate_spec.rb
|
254
289
|
- spec/integration/basic_get_spec.rb
|
290
|
+
- spec/integration/basic_return_spec.rb
|
255
291
|
- spec/integration/channel_close_spec.rb
|
292
|
+
- spec/integration/channel_level_exception_handling_spec.rb
|
256
293
|
- spec/integration/channel_level_exception_with_multiple_channels_spec.rb
|
294
|
+
- spec/integration/connection_level_exception_handling_spec.rb
|
257
295
|
- spec/integration/declare_and_immediately_bind_a_server_named_queue_spec.rb
|
296
|
+
- spec/integration/declare_one_hundred_server_named_queues_spec.rb
|
297
|
+
- spec/integration/direct_exchange_routing_spec.rb
|
258
298
|
- spec/integration/exchange_declaration_spec.rb
|
259
|
-
- spec/integration/extensions/
|
299
|
+
- spec/integration/extensions/rabbitmq/publisher_confirmations_spec.rb
|
300
|
+
- spec/integration/fanout_exchange_routing_spec.rb
|
301
|
+
- spec/integration/headers_exchange_routing_spec.rb
|
302
|
+
- spec/integration/hello_world_spec.rb
|
303
|
+
- spec/integration/immediate_messages_spec.rb
|
304
|
+
- spec/integration/mandatory_messages_spec.rb
|
305
|
+
- spec/integration/message_metadata_access_spec.rb
|
306
|
+
- spec/integration/multiple_consumers_per_queue_spec.rb
|
307
|
+
- spec/integration/ordering_of_published_messages_spec.rb
|
260
308
|
- spec/integration/queue_declaration_spec.rb
|
261
309
|
- spec/integration/queue_exclusivity_spec.rb
|
262
310
|
- spec/integration/queue_redeclaration_with_incompatible_attributes_spec.rb
|
311
|
+
- spec/integration/queue_status_spec.rb
|
312
|
+
- spec/integration/recovery/per_channel_automatic_recovery_on_graceful_broker_shutdown_spec.rb
|
313
|
+
- spec/integration/recovery/per_channel_automatic_recovery_spec.rb
|
314
|
+
- spec/integration/redelivery_of_unacknowledged_messages_spec.rb
|
315
|
+
- spec/integration/regressions/concurrent_publishing_on_the_same_channel_spec.rb
|
316
|
+
- spec/integration/regressions/empty_message_body_spec.rb
|
263
317
|
- spec/integration/regressions/issue66_spec.rb
|
264
318
|
- spec/integration/reply_queue_communication_spec.rb
|
265
319
|
- spec/integration/store_and_forward_spec.rb
|
266
320
|
- spec/integration/topic_subscription_spec.rb
|
267
|
-
- spec/integration/
|
321
|
+
- spec/integration/tx_commit_spec.rb
|
322
|
+
- spec/integration/tx_rollback_spec.rb
|
268
323
|
- spec/spec_helper.rb
|
269
|
-
- spec/unit/amqp/
|
324
|
+
- spec/unit/amqp/bit_set_spec.rb
|
325
|
+
- spec/unit/amqp/channel_id_allocation_spec.rb
|
270
326
|
- spec/unit/amqp/client_spec.rb
|
271
327
|
- spec/unit/amqp/connection_spec.rb
|
272
|
-
-
|
328
|
+
- spec/unit/amqp/int_allocator_spec.rb
|
329
|
+
has_rdoc: true
|
273
330
|
homepage: http://github.com/ruby-amqp/amqp
|
274
331
|
licenses: []
|
275
332
|
|
276
|
-
post_install_message: "[\e[32mVersion 0.8.0\e[0m] [API]
|
333
|
+
post_install_message: "[\e[32mVersion 0.8.0\e[0m] [API] AMQP::Exchange#publish calls now use a mutex on the channel exchange is declared on. Sharing channels between threads is discouraged but amqp gem covers your back in the most dangerous case.\n\
|
334
|
+
[\e[32mVersion 0.8.0\e[0m] [API] AMQP::Channel#synchronize now can be used to guarantee mutual exclusion of multiple threads on channel instances.\n\
|
335
|
+
[\e[32mVersion 0.8.0\e[0m] [BUG] Empty messages can finally be published fine. Yes, it took us just 3 years.\n\
|
336
|
+
[\e[32mVersion 0.8.0\e[0m] [FEATURE] When connected to RabbitMQ, RabbitMQ-specific extensions are required automatically\n\
|
337
|
+
[\e[32mVersion 0.8.0\e[0m] [FEATURE] AMQP::Session#broker and AMQP::Broker allow for broker capabilities inspection\n\
|
338
|
+
[\e[32mVersion 0.8.0\e[0m] [FEATURE] New bitset-based channel id allocator\n\
|
339
|
+
[\e[32mVersion 0.8.0\e[0m] [FEATURE] Multiple consumers per queue with AMQP::Consumer\n\
|
340
|
+
[\e[32mVersion 0.8.0\e[0m] [FEATURE] Automatic recovery mode for channels\n\
|
341
|
+
[\e[32mVersion 0.8.0\e[0m] [FEATURE] Network connection recovery callbacks for channels, exchanges, queues, consumers\n\
|
342
|
+
[\e[32mVersion 0.8.0\e[0m] [API] Connection URI (string) format for vhosts no longer assumes that vhosts begin with a slash (/), learn more at http://bit.ly/mfzwcB\n\
|
277
343
|
[\e[32mVersion 0.8.0\e[0m] [FEATURE] Returned messages, including header & content via AMQP::Exchange#on_publish. Callback accepts 3 args: basic_return, header, body\n\
|
278
344
|
[\e[32mVersion 0.8.0\e[0m] [BUG] Ruby 1.8.7-p249 is not supported because of this (p249-specific) Ruby bug: http://bit.ly/iONBmH\n\
|
279
345
|
[\e[32mVersion 0.8.0\e[0m] [FEATURE] AMQP::Utilities::EventLoopHelper detects app server (if any) being used and starts EventMachine reactor in an optimal way.\n\
|
@@ -336,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
402
|
requirements: []
|
337
403
|
|
338
404
|
rubyforge_project: amqp
|
339
|
-
rubygems_version: 1.
|
405
|
+
rubygems_version: 1.6.2
|
340
406
|
signing_key:
|
341
407
|
specification_version: 3
|
342
408
|
summary: Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries included
|