amqp 0.7.5 → 0.8.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -4
- data/.travis.yml +3 -5
- data/.yardopts +6 -0
- data/CHANGELOG +26 -7
- data/Gemfile +15 -7
- data/README.textile +216 -0
- data/Rakefile +0 -6
- data/amqp.gemspec +14 -4
- data/bin/jenkins.sh +27 -0
- data/bin/set_test_suite_realms_up.sh +16 -2
- data/docs/VendorSpecificExtensions.textile +32 -0
- data/examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb +53 -0
- data/examples/hello_world.rb +29 -0
- data/examples/real-world/task-queue/README.textile +3 -0
- data/examples/real-world/task-queue/consumer.rb +27 -0
- data/examples/real-world/task-queue/producer.rb +22 -0
- data/examples/various/ack.rb +70 -0
- data/examples/various/automatic_binding_for_default_direct_exchange.rb +53 -0
- data/examples/various/basic_get.rb +65 -0
- data/examples/various/callbacks.rb +45 -0
- data/examples/various/clock.rb +74 -0
- data/examples/various/declare_a_queue_without_assignment.rb +46 -0
- data/examples/various/declare_an_exchange_without_assignment.rb +46 -0
- data/examples/various/hashtable.rb +60 -0
- data/examples/{logger.rb → various/logger.rb} +9 -7
- data/examples/{multiclock.rb → various/multiclock.rb} +15 -17
- data/examples/various/open_channel_without_assignment.rb +34 -0
- data/examples/various/pingpong.rb +53 -0
- data/examples/various/primes-simple.rb +29 -0
- data/examples/various/primes.rb +76 -0
- data/examples/various/pubsub.rb +43 -0
- data/examples/various/queue_status.rb +58 -0
- data/examples/various/stocks.rb +59 -0
- data/examples/various/weather_updates.rb +63 -0
- data/lib/amqp.rb +11 -2
- data/lib/amqp/basic_client.rb +23 -54
- data/lib/amqp/channel.rb +577 -805
- data/lib/amqp/client.rb +37 -275
- data/lib/amqp/connection.rb +165 -93
- data/lib/amqp/deprecated/fork.rb +15 -0
- data/lib/amqp/deprecated/logger.rb +99 -0
- data/lib/amqp/deprecated/mq.rb +20 -0
- data/lib/amqp/deprecated/rpc.rb +168 -0
- data/lib/amqp/exchange.rb +409 -281
- data/lib/amqp/extensions/rabbitmq.rb +1 -0
- data/lib/amqp/header.rb +41 -17
- data/lib/amqp/logger.rb +10 -84
- data/lib/amqp/queue.rb +457 -320
- data/lib/amqp/rpc.rb +11 -107
- data/lib/amqp/version.rb +1 -1
- data/lib/mq.rb +2 -1
- data/lib/mq/logger.rb +2 -0
- data/lib/mq/rpc.rb +2 -0
- data/spec/integration/authentication_spec.rb +36 -40
- data/spec/integration/automatic_binding_for_default_direct_exchange_spec.rb +3 -5
- data/spec/integration/basic_get_spec.rb +91 -0
- data/spec/integration/channel_close_spec.rb +5 -5
- data/spec/integration/exchange_declaration_spec.rb +6 -53
- data/spec/integration/extensions/basic_return_spec.rb +47 -0
- data/spec/integration/queue_declaration_spec.rb +14 -17
- data/spec/integration/queue_exclusivity_spec.rb +49 -48
- data/spec/integration/reply_queue_communication_spec.rb +6 -4
- data/spec/integration/store_and_forward_spec.rb +9 -36
- data/spec/integration/topic_subscription_spec.rb +1 -1
- data/spec/integration/workload_distribution_spec.rb +1 -0
- data/spec/spec_helper.rb +69 -43
- data/spec/unit/amqp/connection_spec.rb +27 -23
- data/tasks.rb +11 -0
- metadata +124 -95
- data/README.md +0 -156
- data/TODO +0 -30
- data/amqp.pre.gemspec +0 -6
- data/examples/ack.rb +0 -47
- data/examples/automatic_binding_for_default_direct_exchange.rb +0 -65
- data/examples/callbacks.rb +0 -40
- data/examples/clock.rb +0 -65
- data/examples/default_channel.rb +0 -19
- data/examples/hashtable.rb +0 -61
- data/examples/immediately_bind_a_server_named_queue.rb +0 -38
- data/examples/internal.rb +0 -51
- data/examples/issues/issue_75.rb +0 -21
- data/examples/issues/issue_94.rb +0 -23
- data/examples/pingpong.rb +0 -54
- data/examples/pop.rb +0 -45
- data/examples/primes-simple.rb +0 -21
- data/examples/primes.rb +0 -101
- data/examples/simple.rb +0 -81
- data/examples/stocks.rb +0 -67
- data/gemfiles/eventmachine-pre +0 -24
- data/lib/amqp/buffer.rb +0 -272
- data/lib/amqp/collection.rb +0 -60
- data/lib/amqp/frame.rb +0 -68
- data/lib/amqp/protocol.rb +0 -163
- data/lib/amqp/server.rb +0 -101
- data/lib/amqp/spec.rb +0 -832
- data/protocol/amqp-0.8.json +0 -617
- data/protocol/amqp-0.8.xml +0 -3908
- data/protocol/codegen.rb +0 -175
- data/protocol/doc.txt +0 -281
- data/research/api.rb +0 -52
- data/research/primes-forked.rb +0 -65
- data/research/primes-processes.rb +0 -137
- data/research/primes-threaded.rb +0 -51
- data/spec/integration/queue_status_spec.rb +0 -44
- data/spec/unit/amqp/buffer_spec.rb +0 -178
- data/spec/unit/amqp/client_spec.rb +0 -102
- data/spec/unit/amqp/collection_spec.rb +0 -144
- data/spec/unit/amqp/frame_spec.rb +0 -60
- data/spec/unit/amqp/protocol_spec.rb +0 -51
@@ -1,102 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe AMQP::Client do
|
6
|
-
|
7
|
-
#
|
8
|
-
# Examples
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
describe ".parse_connection_uri(connection_string)" do
|
13
|
-
context "when schema is not one of [amqp, amqps]" do
|
14
|
-
it "raises ArgumentError" do
|
15
|
-
expect {
|
16
|
-
described_class.parse_connection_uri("http://dev.rabbitmq.com")
|
17
|
-
}.to raise_error(ArgumentError, /amqp or amqps schema/)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
it "handles amqp:// URIs w/o path part" do
|
23
|
-
val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com")
|
24
|
-
|
25
|
-
val[:vhost].should be_nil # in this case, default / will be used
|
26
|
-
val[:host].should == "dev.rabbitmq.com"
|
27
|
-
val[:port].should == 5672
|
28
|
-
val[:scheme].should == "amqp"
|
29
|
-
val[:ssl].should be_false
|
30
|
-
end
|
31
|
-
|
32
|
-
it "handles amqps:// URIs w/o path part" do
|
33
|
-
val = described_class.parse_connection_uri("amqps://dev.rabbitmq.com")
|
34
|
-
|
35
|
-
val[:vhost].should be_nil
|
36
|
-
val[:host].should == "dev.rabbitmq.com"
|
37
|
-
val[:port].should == 5671
|
38
|
-
val[:scheme].should == "amqps"
|
39
|
-
val[:ssl].should be_true
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
context "when URI ends in a slash" do
|
44
|
-
it "parses vhost as an empty string" do
|
45
|
-
val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com/")
|
46
|
-
|
47
|
-
val[:host].should == "dev.rabbitmq.com"
|
48
|
-
val[:port].should == 5672
|
49
|
-
val[:scheme].should == "amqp"
|
50
|
-
val[:ssl].should be_false
|
51
|
-
val[:vhost].should == ""
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
context "when URI ends in /%2Fvault" do
|
57
|
-
it "parses vhost as /vault" do
|
58
|
-
val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com/%2Fvault")
|
59
|
-
|
60
|
-
val[:host].should == "dev.rabbitmq.com"
|
61
|
-
val[:port].should == 5672
|
62
|
-
val[:scheme].should == "amqp"
|
63
|
-
val[:ssl].should be_false
|
64
|
-
val[:vhost].should == "/vault"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
context "when URI is amqp://dev.rabbitmq.com/a.path.without.slashes" do
|
70
|
-
it "parses vhost as a.path.without.slashes" do
|
71
|
-
val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com/a.path.without.slashes")
|
72
|
-
|
73
|
-
val[:host].should == "dev.rabbitmq.com"
|
74
|
-
val[:port].should == 5672
|
75
|
-
val[:scheme].should == "amqp"
|
76
|
-
val[:ssl].should be_false
|
77
|
-
val[:vhost].should == "a.path.without.slashes"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "when URI is amqp://dev.rabbitmq.com/a/path/with/slashes" do
|
82
|
-
it "raises an ArgumentError" do
|
83
|
-
lambda { described_class.parse_connection_uri("amqp://dev.rabbitmq.com/a/path/with/slashes") }.should raise_error(ArgumentError)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
context "when URI has username:password, for instance, amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal" do
|
89
|
-
it "parses them out" do
|
90
|
-
val = described_class.parse_connection_uri("amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal")
|
91
|
-
|
92
|
-
val[:host].should == "hub.megacorp.internal"
|
93
|
-
val[:port].should == 5672
|
94
|
-
val[:scheme].should == "amqp"
|
95
|
-
val[:ssl].should be_false
|
96
|
-
val[:user].should == "hedgehog"
|
97
|
-
val[:pass].should == "t0ps3kr3t"
|
98
|
-
val[:vhost].should be_nil # in this case, default / will be used
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "amqp/collection"
|
5
|
-
|
6
|
-
Item = Struct.new(:name)
|
7
|
-
|
8
|
-
describe AMQP::Collection do
|
9
|
-
before do
|
10
|
-
@items = 3.times.map { |int| Item.new("name-#{int}") }
|
11
|
-
@collection = AMQP::Collection.new(@items)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "provides access to items by name" do
|
15
|
-
@collection["name-1"].should_not be_nil
|
16
|
-
@collection["name-1"].should eql(@items[1])
|
17
|
-
end
|
18
|
-
|
19
|
-
it "DOES NOT allow modification of existing items" do
|
20
|
-
lambda { @collection["name-1"] = Item.new("test") }.should raise_error(NoMethodError)
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
describe "#<<" do
|
25
|
-
it "should raise IncompatibleItemError if the argument doesn't have method :name" do
|
26
|
-
lambda { @collection << nil }.should raise_error(AMQP::Collection::IncompatibleItemError)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should add an item into the collection" do
|
30
|
-
length = @collection.length
|
31
|
-
@collection << Item.new("test")
|
32
|
-
@collection.length.should eql(length + 1)
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when another item with given name already exists and the name IS NOT nil" do
|
36
|
-
it "should not add an item to the collection" do
|
37
|
-
@collection << Item.new("test")
|
38
|
-
length = @collection.length
|
39
|
-
@collection << Item.new("test")
|
40
|
-
@collection.length.should eql(length)
|
41
|
-
end # it
|
42
|
-
end # context
|
43
|
-
|
44
|
-
|
45
|
-
context "when another item with given name already exists and the name IS nil" do
|
46
|
-
it "should add an item to the collection" do
|
47
|
-
@collection << Item.new(nil)
|
48
|
-
length = @collection.length
|
49
|
-
@collection << Item.new(nil)
|
50
|
-
@collection.length.should eql(length + 1)
|
51
|
-
end # it
|
52
|
-
end # context
|
53
|
-
|
54
|
-
it "should return the item" do
|
55
|
-
item = Item.new("test")
|
56
|
-
(@collection << item).should eql item
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when adding new item with duplicate name" do
|
60
|
-
before do
|
61
|
-
@original_item = Item.new("test")
|
62
|
-
@new_item = Item.new("test")
|
63
|
-
@collection << @original_item
|
64
|
-
end
|
65
|
-
|
66
|
-
it "keeps item already in collection" do
|
67
|
-
@collection << @new_item
|
68
|
-
@collection['test'].should eql @original_item
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns item already in collection" do
|
72
|
-
(@collection << @new_item).should eql @original_item
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "when item we add already exists in the collection" do
|
77
|
-
it "should return the item" do
|
78
|
-
item = Item.new("test")
|
79
|
-
@collection << item
|
80
|
-
(@collection << item).should eql item
|
81
|
-
end # it
|
82
|
-
end # context
|
83
|
-
end # describe
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
describe "#add!" do
|
89
|
-
context "when the argument doesn't respond to :name" do
|
90
|
-
it "should raise IncompatibleItemError " do
|
91
|
-
lambda { @collection.add!(nil) }.should raise_error(AMQP::Collection::IncompatibleItemError)
|
92
|
-
end # it
|
93
|
-
end
|
94
|
-
|
95
|
-
context "when another item with given name already exists" do
|
96
|
-
it "should add an item to the collection" do
|
97
|
-
@collection.add! Item.new("test")
|
98
|
-
lambda do
|
99
|
-
@collection.add!(Item.new("test"))
|
100
|
-
end.should change(@collection, :length).by(1)
|
101
|
-
end # it
|
102
|
-
end # context
|
103
|
-
|
104
|
-
it "should return the item" do
|
105
|
-
item = Item.new("test")
|
106
|
-
(@collection.add! item).should eql(item)
|
107
|
-
end # it
|
108
|
-
end # describe
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
describe "#<<" do
|
115
|
-
context "when the argument doesn't respond to :name" do
|
116
|
-
it "should raise IncompatibleItemError " do
|
117
|
-
lambda { @collection << nil }.should raise_error(AMQP::Collection::IncompatibleItemError)
|
118
|
-
end # it
|
119
|
-
end # context
|
120
|
-
|
121
|
-
context "when the argument DOES respond to :name" do
|
122
|
-
it "should add an item into the collection" do
|
123
|
-
lambda do
|
124
|
-
@collection << Item.new("test")
|
125
|
-
end.should change(@collection, :length).by(1)
|
126
|
-
end
|
127
|
-
end # context
|
128
|
-
end # describe
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
describe "#delete" do
|
135
|
-
it "should remove item with the given name from the collection" do
|
136
|
-
items = [Item.new("test-0"), Item.new("test-1")]
|
137
|
-
collection = AMQP::Collection.new(items)
|
138
|
-
lambda {
|
139
|
-
collection.delete("test-1")
|
140
|
-
}.should change(collection, :length).by(-1)
|
141
|
-
collection.should_not include("test-1")
|
142
|
-
end
|
143
|
-
end # describe
|
144
|
-
end # describe AMQP::Collection
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
require "spec_helper"
|
5
|
-
require "amqp/frame"
|
6
|
-
|
7
|
-
describe AMQP::Frame do
|
8
|
-
include AMQP
|
9
|
-
|
10
|
-
it 'should handle basic frame types' do
|
11
|
-
AMQP::Frame::Method.new.id.should == 1
|
12
|
-
AMQP::Frame::Header.new.id.should == 2
|
13
|
-
AMQP::Frame::Body.new.id.should == 3
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should convert method frames to binary' do
|
17
|
-
meth = AMQP::Protocol::Connection::Secure.new :challenge => 'secret'
|
18
|
-
|
19
|
-
frame = AMQP::Frame::Method.new(meth)
|
20
|
-
frame.to_binary.should be_kind_of(AMQP::Buffer)
|
21
|
-
frame.to_s.should == [1, 0, meth.to_s.length, meth.to_s, 206].pack('CnNa*C')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should convert binary to method frames' do
|
25
|
-
orig = AMQP::Frame::Method.new(AMQP::Protocol::Connection::Secure.new(:challenge => 'secret'))
|
26
|
-
|
27
|
-
copy = AMQP::Frame.parse(orig.to_binary)
|
28
|
-
copy.should == orig
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should ignore partial frames until ready' do
|
32
|
-
frame = AMQP::Frame::Method.new(AMQP::Protocol::Connection::Secure.new(:challenge => 'secret'))
|
33
|
-
data = frame.to_s
|
34
|
-
|
35
|
-
buf = AMQP::Buffer.new
|
36
|
-
AMQP::Frame.parse(buf).should == nil
|
37
|
-
|
38
|
-
buf << data[0..5]
|
39
|
-
AMQP::Frame.parse(buf).should == nil
|
40
|
-
|
41
|
-
buf << data[6..-1]
|
42
|
-
AMQP::Frame.parse(buf).should == frame
|
43
|
-
|
44
|
-
AMQP::Frame.parse(buf).should == nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should convert header frames to binary' do
|
48
|
-
head = AMQP::Protocol::Header.new(AMQP::Protocol::Basic, :priority => 1)
|
49
|
-
|
50
|
-
frame = AMQP::Frame::Header.new(head)
|
51
|
-
frame.to_s.should == [2, 0, head.to_s.length, head.to_s, 206].pack('CnNa*C')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should convert binary to header frame' do
|
55
|
-
orig = AMQP::Frame::Header.new(AMQP::Protocol::Header.new(AMQP::Protocol::Basic, :priority => 1))
|
56
|
-
|
57
|
-
copy = AMQP::Frame.parse(orig.to_binary)
|
58
|
-
copy.should == orig
|
59
|
-
end
|
60
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "amqp/protocol"
|
5
|
-
|
6
|
-
describe AMQP::Protocol do
|
7
|
-
it 'should instantiate methods with arguments' do
|
8
|
-
meth = AMQP::Protocol::Connection::StartOk.new nil, 'PLAIN', nil, 'en_US'
|
9
|
-
meth.locale.should == 'en_US'
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should instantiate methods with named parameters' do
|
13
|
-
meth = AMQP::Protocol::Connection::StartOk.new :locale => 'en_US',
|
14
|
-
:mechanism => 'PLAIN'
|
15
|
-
meth.locale.should == 'en_US'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should convert methods to binary' do
|
19
|
-
meth = AMQP::Protocol::Connection::Secure.new :challenge => 'secret'
|
20
|
-
meth.to_binary.should be_kind_of AMQP::Buffer
|
21
|
-
|
22
|
-
meth.to_s.should == [10, 20, 6, 'secret'].pack('nnNa*')
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should convert binary to method' do
|
26
|
-
orig = AMQP::Protocol::Connection::Secure.new :challenge => 'secret'
|
27
|
-
copy = AMQP::Protocol.parse orig.to_binary
|
28
|
-
orig.should == copy
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should convert headers to binary' do
|
32
|
-
head = AMQP::Protocol::Header.new AMQP::Protocol::Basic,
|
33
|
-
size = 5,
|
34
|
-
weight = 0,
|
35
|
-
:content_type => 'text/json',
|
36
|
-
:delivery_mode => 1,
|
37
|
-
:priority => 1
|
38
|
-
head.to_s.should ==
|
39
|
-
[60, weight, 0, size, 0b1001_1000_0000_0000, 9, 'text/json', 1, 1].pack('nnNNnCa*CC')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should convert binary to header' do
|
43
|
-
orig = AMQP::Protocol::Header.new AMQP::Protocol::Basic,
|
44
|
-
size = 5,
|
45
|
-
weight = 0,
|
46
|
-
:content_type => 'text/json',
|
47
|
-
:delivery_mode => 1,
|
48
|
-
:priority => 1
|
49
|
-
AMQP::Protocol::Header.new(orig.to_binary).should == orig
|
50
|
-
end
|
51
|
-
end
|