bunny 0.7.13 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -2
- data/.travis.yml +7 -16
- data/CHANGELOG +3 -21
- data/Gemfile +2 -4
- data/README.textile +31 -9
- data/Rakefile +3 -3
- data/bunny.gemspec +6 -3
- data/examples/{simple_08.rb → simple.rb} +1 -1
- data/examples/{simple_ack_08.rb → simple_ack.rb} +1 -1
- data/examples/{simple_consumer_08.rb → simple_consumer.rb} +4 -4
- data/examples/{simple_fanout_08.rb → simple_fanout.rb} +1 -1
- data/examples/{simple_headers_08.rb → simple_headers.rb} +2 -2
- data/examples/{simple_publisher_09.rb → simple_publisher.rb} +1 -1
- data/examples/{simple_topic_09.rb → simple_topic.rb} +2 -2
- data/ext/amqp-0.9.1.json +1 -0
- data/ext/config.yml +3 -3
- data/ext/qparser.rb +9 -52
- data/lib/bunny/{client09.rb → client.rb} +34 -46
- data/lib/bunny/{exchange09.rb → exchange.rb} +16 -15
- data/lib/bunny/{queue09.rb → queue.rb} +26 -23
- data/lib/bunny/{subscription09.rb → subscription.rb} +11 -6
- data/lib/bunny/version.rb +1 -1
- data/lib/bunny.rb +15 -33
- data/lib/qrack/client.rb +31 -22
- data/lib/qrack/protocol/{protocol08.rb → protocol.rb} +2 -1
- data/lib/qrack/protocol/{spec09.rb → spec.rb} +8 -7
- data/lib/qrack/{qrack08.rb → qrack.rb} +4 -4
- data/lib/qrack/subscription.rb +58 -9
- data/lib/qrack/transport/{buffer08.rb → buffer.rb} +9 -1
- data/lib/qrack/transport/{frame08.rb → frame.rb} +7 -22
- data/spec/spec_09/amqp_url_spec.rb +1 -1
- data/spec/spec_09/bunny_spec.rb +11 -9
- data/spec/spec_09/connection_spec.rb +9 -4
- data/spec/spec_09/exchange_spec.rb +23 -25
- data/spec/spec_09/queue_spec.rb +33 -19
- metadata +71 -81
- checksums.yaml +0 -7
- data/examples/simple_09.rb +0 -32
- data/examples/simple_ack_09.rb +0 -35
- data/examples/simple_consumer_09.rb +0 -55
- data/examples/simple_fanout_09.rb +0 -41
- data/examples/simple_headers_09.rb +0 -42
- data/examples/simple_publisher_08.rb +0 -29
- data/examples/simple_topic_08.rb +0 -61
- data/ext/amqp-0.8.json +0 -616
- data/lib/bunny/channel09.rb +0 -39
- data/lib/bunny/client08.rb +0 -480
- data/lib/bunny/exchange08.rb +0 -177
- data/lib/bunny/queue08.rb +0 -403
- data/lib/bunny/subscription08.rb +0 -87
- data/lib/qrack/protocol/protocol09.rb +0 -135
- data/lib/qrack/protocol/spec08.rb +0 -828
- data/lib/qrack/qrack09.rb +0 -20
- data/lib/qrack/transport/buffer09.rb +0 -305
- data/lib/qrack/transport/frame09.rb +0 -97
- data/spec/spec_08/bunny_spec.rb +0 -75
- data/spec/spec_08/connection_spec.rb +0 -24
- data/spec/spec_08/exchange_spec.rb +0 -175
- data/spec/spec_08/queue_spec.rb +0 -239
- data/spec/spec_helper.rb +0 -8
- /data/lib/bunny/{channel08.rb → channel.rb} +0 -0
data/spec/spec_08/queue_spec.rb
DELETED
@@ -1,239 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# queue_spec.rb
|
4
|
-
|
5
|
-
# Assumes that target message broker/server has a user called 'guest' with a password 'guest'
|
6
|
-
# and that it is running on 'localhost'.
|
7
|
-
|
8
|
-
# If this is not the case, please change the 'Bunny.new' call below to include
|
9
|
-
# the relevant arguments e.g. @b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
|
10
|
-
|
11
|
-
require_relative "../spec_helper"
|
12
|
-
|
13
|
-
describe 'Queue' do
|
14
|
-
|
15
|
-
def expect_deprecation_warning_for_publishing_on_queue(q, n=1)
|
16
|
-
expect(Bunny).to receive(:deprecation_warning).with("Qrack::Queue#publish", "0.8", anything).exactly(n).times
|
17
|
-
end
|
18
|
-
|
19
|
-
def message_count(queue, sleep_time = 0.1)
|
20
|
-
sleep sleep_time
|
21
|
-
queue.message_count
|
22
|
-
end
|
23
|
-
|
24
|
-
before(:each) do
|
25
|
-
@b = Bunny.new
|
26
|
-
@b.start
|
27
|
-
end
|
28
|
-
|
29
|
-
after(:each) do
|
30
|
-
begin
|
31
|
-
@b.stop
|
32
|
-
rescue Exception
|
33
|
-
ensure
|
34
|
-
@b = nil
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should ignore the :nowait option when instantiated" do
|
39
|
-
q = @b.queue('test0', :nowait => true)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should ignore the :nowait option when binding to an exchange" do
|
43
|
-
exch = @b.exchange('direct_exch')
|
44
|
-
q = @b.queue('test0')
|
45
|
-
q.bind(exch, :nowait => true).should == :bind_ok
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should be able to bind to an existing exchange" do
|
49
|
-
exch = @b.exchange('direct_exch')
|
50
|
-
q = @b.queue('test1')
|
51
|
-
q.bind(exch).should == :bind_ok
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should ignore the :nowait option when unbinding from an exchange" do
|
55
|
-
exch = @b.exchange('direct_exch')
|
56
|
-
q = @b.queue('test0')
|
57
|
-
q.unbind(exch, :nowait => true).should == :unbind_ok
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should not raise an error if unbinding from a non-existent exchange" do
|
61
|
-
q = @b.queue('test1')
|
62
|
-
q.unbind('bogus').should == :unbind_ok
|
63
|
-
@b.channel.active.should == true
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should be able to unbind from an existing exchange" do
|
67
|
-
exch = @b.exchange('direct_exch')
|
68
|
-
q = @b.queue('test1')
|
69
|
-
q.unbind(exch).should == :unbind_ok
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should be able to publish a message" do
|
73
|
-
q = @b.queue('test1')
|
74
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
75
|
-
q.publish('This is a test message')
|
76
|
-
message_count(q).should == 1
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should be able to pop a message complete with header and delivery details" do
|
80
|
-
q = @b.queue('test1')
|
81
|
-
msg = q.pop()
|
82
|
-
msg.should be_an_instance_of(Hash)
|
83
|
-
msg[:header].should be_an_instance_of(Bunny::Protocol::Header)
|
84
|
-
msg[:payload].should == 'This is a test message'
|
85
|
-
msg[:delivery_details].should be_an_instance_of(Hash)
|
86
|
-
message_count(q).should == 0
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should be able to pop a message and just get the payload" do
|
90
|
-
q = @b.queue('test1')
|
91
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
92
|
-
q.publish('This is another test message')
|
93
|
-
msg = q.pop[:payload]
|
94
|
-
msg.should == 'This is another test message'
|
95
|
-
message_count(q).should == 0
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should be able to pop a message where body length exceeds max frame size" do
|
99
|
-
q = @b.queue('test1')
|
100
|
-
lg_msg = 'z' * 142000
|
101
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
102
|
-
q.publish(lg_msg)
|
103
|
-
msg = q.pop[:payload]
|
104
|
-
msg.should == lg_msg
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should be able to send and receive messages where body length is an exact multiple of frame_max minus framing bytes" do
|
108
|
-
limit = @b.frame_max-8
|
109
|
-
q = @b.queue('test1')
|
110
|
-
lg_msg = 'a' * (5*limit)
|
111
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
112
|
-
q.publish(lg_msg)
|
113
|
-
msg = q.pop[:payload]
|
114
|
-
msg.should == lg_msg
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should be able call a block when popping a message" do
|
118
|
-
q = @b.queue('test1')
|
119
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
120
|
-
q.publish('This is another test message')
|
121
|
-
q.pop { |msg| msg[:payload].should == 'This is another test message' }
|
122
|
-
q.pop { |msg| msg[:payload].should == :queue_empty }
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should raise an error if purge fails" do
|
126
|
-
q = @b.queue('test1')
|
127
|
-
expect_deprecation_warning_for_publishing_on_queue(q, 5)
|
128
|
-
5.times {q.publish('This is another test message')}
|
129
|
-
message_count(q).should == 5
|
130
|
-
lambda {q.purge(:queue => 'bogus')}.should raise_error(Bunny::ForcedChannelCloseError)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should be able to be purged to remove all of its messages" do
|
134
|
-
q = @b.queue('test1')
|
135
|
-
message_count(q).should == 5
|
136
|
-
q.purge.should == :purge_ok
|
137
|
-
message_count(q).should == 0
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should return an empty message when popping an empty queue" do
|
141
|
-
q = @b.queue('test1')
|
142
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
143
|
-
q.publish('This is another test message')
|
144
|
-
q.pop
|
145
|
-
msg = q.pop[:payload]
|
146
|
-
msg.should == :queue_empty
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should stop subscription without processing messages if max specified is 0" do
|
150
|
-
q = @b.queue('test1')
|
151
|
-
expect_deprecation_warning_for_publishing_on_queue(q, 5)
|
152
|
-
5.times {q.publish('Yet another test message')}
|
153
|
-
message_count(q).should == 5
|
154
|
-
q.subscribe(:message_max => 0)
|
155
|
-
message_count(q).should == 5
|
156
|
-
q.purge.should == :purge_ok
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should stop subscription after processing number of messages specified > 0" do
|
160
|
-
q = @b.queue('test1')
|
161
|
-
expect_deprecation_warning_for_publishing_on_queue(q, 5)
|
162
|
-
5.times {q.publish('Yet another test message')}
|
163
|
-
message_count(q).should == 5
|
164
|
-
q.subscribe(:message_max => 5)
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should stop subscription after processing message_max messages < total in queue" do
|
168
|
-
q = @b.queue('test1')
|
169
|
-
@b.qos()
|
170
|
-
expect_deprecation_warning_for_publishing_on_queue(q, 10)
|
171
|
-
10.times {q.publish('Yet another test message')}
|
172
|
-
message_count(q).should == 10
|
173
|
-
q.subscribe(:message_max => 5, :ack => true)
|
174
|
-
message_count(q).should == 5
|
175
|
-
q.purge.should == :purge_ok
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should not close the connections when deleting a non existent queue" do
|
179
|
-
q = @b.queue('test1')
|
180
|
-
q.delete(:queue => 'bogus').should == :delete_ok
|
181
|
-
@b.channel.active.should == true
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should pass correct block parameters through on subscribe" do
|
185
|
-
q = @b.queue('test1')
|
186
|
-
expect_deprecation_warning_for_publishing_on_queue(q)
|
187
|
-
q.publish("messages pop\'n")
|
188
|
-
|
189
|
-
q.subscribe do |msg|
|
190
|
-
msg[:header].should be_an_instance_of Qrack::Protocol::Header
|
191
|
-
msg[:payload].should == "messages pop'n"
|
192
|
-
msg[:delivery_details].should_not be_nil
|
193
|
-
|
194
|
-
q.unsubscribe
|
195
|
-
break
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should finish processing subscription messages if break is called in block" do
|
200
|
-
q = @b.queue('test1')
|
201
|
-
expect_deprecation_warning_for_publishing_on_queue(q, 6)
|
202
|
-
q.publish('messages in my quezen')
|
203
|
-
|
204
|
-
q.subscribe do |msg|
|
205
|
-
msg[:payload].should == 'messages in my quezen'
|
206
|
-
q.unsubscribe
|
207
|
-
break
|
208
|
-
end
|
209
|
-
|
210
|
-
5.times {|i| q.publish("#{i}")}
|
211
|
-
q.subscribe do |msg|
|
212
|
-
if msg[:payload] == '4'
|
213
|
-
q.unsubscribe
|
214
|
-
break
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should be able to be deleted" do
|
220
|
-
q = @b.queue('test1')
|
221
|
-
res = q.delete
|
222
|
-
res.should == :delete_ok
|
223
|
-
@b.queues.has_key?('test1').should be(false)
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should ignore the :nowait option when deleted" do
|
227
|
-
q = @b.queue('test0')
|
228
|
-
q.delete(:nowait => true)
|
229
|
-
end
|
230
|
-
|
231
|
-
it "should support server named queues" do
|
232
|
-
q = @b.queue
|
233
|
-
q.name.should_not == nil
|
234
|
-
|
235
|
-
@b.queue(q.name).should == q
|
236
|
-
q.delete
|
237
|
-
end
|
238
|
-
|
239
|
-
end
|
data/spec/spec_helper.rb
DELETED
File without changes
|