bunny 0.7.9 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 072792fbee28a7ddb863068d4d50082734814fcf
4
+ data.tar.gz: a7c720f93a3b196be83350f0694a15191ecf8148
5
+ SHA512:
6
+ metadata.gz: 20d9da18623a97f363ee15ed57f26b433e4a9328769e2e8993c4c53f33a63e256438f66487c74581ce284dac2729e22dddd787446b605ad965bc40e9382569f7
7
+ data.tar.gz: 8d91cc821840d51811767541b5637246bbc098a71923cd52c3773044519dd5fb000a12532ca4761435e0415e76089d2cf09cad37ccd82ed9038450cd9fe4a1bf
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  .rvmrc
9
9
  Gemfile.lock
10
10
  .rbx/*
11
+ tmp/*
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ = Version 0.7.10
2
+
3
+ * handle messages larger than frame_max correctly
4
+
5
+ = Version 0.7.9
6
+
7
+ * parse a few more AMQ datatypes (related to federation plugin)
8
+
1
9
  = Version 0.7.8
2
10
 
3
11
  * test suite cleanup (eliminated some race conditions related to queue.message_count)
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- source :rubygems
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Use local clones if possible.
6
6
  # If you want to use your local copy, just symlink it to vendor.
@@ -30,6 +30,8 @@ group :development do
30
30
  gem "RedCloth", :platform => :mri
31
31
 
32
32
  gem "changelog"
33
+
34
+ gem "byebug"
33
35
  end
34
36
 
35
37
  group :test do
@@ -189,6 +189,8 @@ Exchange
189
189
  method = frame.payload
190
190
 
191
191
  if method.is_a?(Qrack::Protocol::Connection::Tune)
192
+ @frame_max = method.frame_max if method.frame_max > 0 && method.frame_max < @frame_max
193
+ @channel_max = method.channel_max if method.channel_max > 0 && method.channel_max < @channel_max
192
194
  send_frame(Qrack::Protocol::Connection::TuneOk.new( :channel_max => @channel_max, :frame_max => @frame_max, :heartbeat => @heartbeat))
193
195
  end
194
196
 
@@ -462,6 +464,12 @@ using the Commit or Rollback methods.
462
464
  :select_ok
463
465
  end
464
466
 
467
+ protected
468
+
469
+ def check_returned_message(method)
470
+ check_response(method, Qrack::Protocol::Basic::Return, "Expected a returned message")
471
+ end
472
+
465
473
  private
466
474
 
467
475
  def buffer
@@ -169,6 +169,8 @@ module Bunny
169
169
  method = frame.payload
170
170
 
171
171
  if method.is_a?(Qrack::Protocol09::Connection::Tune)
172
+ @frame_max = method.frame_max if method.frame_max > 0 && method.frame_max < @frame_max
173
+ @channel_max = method.channel_max if method.channel_max > 0 && method.channel_max < @channel_max
172
174
  send_frame(Qrack::Protocol09::Connection::TuneOk.new(:channel_max => @channel_max, :frame_max => @frame_max, :heartbeat => @heartbeat))
173
175
  end
174
176
 
@@ -364,6 +366,12 @@ module Bunny
364
366
  :select_ok
365
367
  end
366
368
 
369
+ protected
370
+
371
+ def check_returned_message(method)
372
+ check_response(method, Qrack::Protocol09::Basic::Return, "Expected a returned message")
373
+ end
374
+
367
375
  private
368
376
 
369
377
  def buffer
@@ -161,7 +161,13 @@ nil
161
161
  :priority => 0
162
162
  }.merge(opts)
163
163
  )
164
- out << Qrack::Transport::Body.new(data)
164
+
165
+ limit = @client.frame_max - 8
166
+ i = 0
167
+ while i < data.bytesize
168
+ out << Qrack::Transport::Body.new(data.byteslice(i, limit))
169
+ i += limit
170
+ end
165
171
 
166
172
  client.send_frame(*out)
167
173
  end
@@ -149,7 +149,13 @@ module Bunny
149
149
  :priority => 0
150
150
  }.merge(opts)
151
151
  )
152
- out << Qrack::Transport09::Body.new(data)
152
+
153
+ limit = @client.frame_max - 8
154
+ i = 0
155
+ while i < data.bytesize
156
+ out << Qrack::Transport09::Body.new(data.byteslice(i, limit))
157
+ i += limit
158
+ end
153
159
 
154
160
  client.send_frame(*out)
155
161
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Bunny
4
- VERSION = "0.7.9"
4
+ VERSION = "0.7.10"
5
5
  end
@@ -20,7 +20,7 @@ module Qrack
20
20
  CONNECT_TIMEOUT = 5.0
21
21
  RETRY_DELAY = 10.0
22
22
 
23
- attr_reader :status, :host, :vhost, :port, :logging, :spec, :heartbeat
23
+ attr_reader :status, :host, :vhost, :port, :logging, :spec, :heartbeat, :frame_max
24
24
  attr_accessor :channel, :logfile, :exchanges, :queues, :channels, :message_in, :message_out, :connecting
25
25
 
26
26
  # Temporary hack to make Bunny 0.7 work with port number in AMQP URL.
@@ -142,6 +142,9 @@ module Qrack
142
142
  end
143
143
 
144
144
  method = frame.payload
145
+ # at this point, we can receive a channel or connection close, which we need to check for
146
+ check_returned_message(method)
147
+
145
148
  header = next_payload
146
149
 
147
150
  # If maximum frame size is smaller than message payload body then message
@@ -63,15 +63,13 @@ describe Bunny do
63
63
  @b.queues.has_key?('test1').should be(true)
64
64
  end
65
65
 
66
- # Current RabbitMQ has not implemented some functionality
67
- it "should raise an error if setting of QoS fails" do
68
- lambda { @b.qos(:global => true) }.should raise_error(Bunny::ForcedConnectionCloseError)
69
- @b.status.should == :not_connected
70
- end
71
-
72
66
  it "should be able to set QoS" do
73
67
  @b.qos.should == :qos_ok
74
68
  end
75
69
 
70
+ it "should be able to set QoS (with global:true)" do
71
+ @b.qos(:global => true).should == :qos_ok
72
+ end
73
+
76
74
  end
77
75
 
@@ -137,25 +137,22 @@ describe 'Exchange' do
137
137
 
138
138
  it "should be able to return an undeliverable message" do
139
139
  exch = @b.exchange('return_exch')
140
- exch.publish('This message should be undeliverable', :immediate => true)
140
+ exch.publish('This message should be undeliverable', :mandatory => true)
141
141
  ret_msg = @b.returned_message
142
142
  ret_msg.should be_an_instance_of(Hash)
143
143
  ret_msg[:payload].should == 'This message should be undeliverable'
144
144
  end
145
145
 
146
- it "should be able to return a message that exceeds maximum frame size" do
146
+ it "should be able to handle connection close on trying to publish with immediate=true" do
147
147
  exch = @b.exchange('return_exch')
148
- lg_msg = 'z' * 142000
149
- exch.publish(lg_msg, :immediate => true)
150
- ret_msg = @b.returned_message
151
- ret_msg.should be_an_instance_of(Hash)
152
- ret_msg[:payload].should == lg_msg
148
+ exch.publish('This message should force a connection close', :immediate => true)
149
+ lambda { @b.returned_message }.should raise_error(Bunny::ForcedConnectionCloseError)
153
150
  end
154
151
 
155
- it "should report an error if delete fails" do
152
+ it "should not close the connection when trying to delete a non existent exchange" do
156
153
  exch = @b.exchange('direct_exchange')
157
- lambda { exch.delete(:exchange => 'bogus_ex') }.should raise_error(Bunny::ForcedChannelCloseError)
158
- @b.channel.active.should == false
154
+ exch.delete(:exchange => 'bogus_ex').should == :delete_ok
155
+ @b.channel.active.should == true
159
156
  end
160
157
 
161
158
  it "should be able to be deleted" do
@@ -45,12 +45,6 @@ describe 'Queue' do
45
45
  q.bind(exch, :nowait => true).should == :bind_ok
46
46
  end
47
47
 
48
- it "should raise an error when trying to bind to a non-existent exchange" do
49
- q = @b.queue('test1')
50
- lambda {q.bind('bogus')}.should raise_error(Bunny::ForcedChannelCloseError)
51
- @b.channel.active.should == false
52
- end
53
-
54
48
  it "should be able to bind to an existing exchange" do
55
49
  exch = @b.exchange('direct_exch')
56
50
  q = @b.queue('test1')
@@ -63,10 +57,10 @@ describe 'Queue' do
63
57
  q.unbind(exch, :nowait => true).should == :unbind_ok
64
58
  end
65
59
 
66
- it "should raise an error if unbinding from a non-existent exchange" do
60
+ it "should not raise an error if unbinding from a non-existent exchange" do
67
61
  q = @b.queue('test1')
68
- lambda {q.unbind('bogus')}.should raise_error(Bunny::ForcedChannelCloseError)
69
- @b.channel.active.should == false
62
+ q.unbind('bogus').should == :unbind_ok
63
+ @b.channel.active.should == true
70
64
  end
71
65
 
72
66
  it "should be able to unbind from an existing exchange" do
@@ -171,10 +165,10 @@ describe 'Queue' do
171
165
  q.purge.should == :purge_ok
172
166
  end
173
167
 
174
- it "should raise an error when delete fails" do
168
+ it "should not close the connections when deleting a non existent queue" do
175
169
  q = @b.queue('test1')
176
- lambda {q.delete(:queue => 'bogus')}.should raise_error(Bunny::ForcedChannelCloseError)
177
- @b.channel.active.should == false
170
+ q.delete(:queue => 'bogus').should == :delete_ok
171
+ @b.channel.active.should == true
178
172
  end
179
173
 
180
174
  it "should pass correct block parameters through on subscribe" do
@@ -63,14 +63,12 @@ describe Bunny do
63
63
  @b.queues.has_key?('test1').should be(true)
64
64
  end
65
65
 
66
- # Current RabbitMQ has not implemented some functionality
67
- it "should raise an error if setting of QoS fails" do
68
- lambda { @b.qos(:global => true) }.should raise_error(Bunny::ForcedConnectionCloseError)
69
- @b.status.should == :not_connected
70
- end
71
-
72
66
  it "should be able to set QoS" do
73
67
  @b.qos.should == :qos_ok
74
68
  end
75
69
 
70
+ it "should be able to set QoS (with global:true)" do
71
+ @b.qos(:global => true).should == :qos_ok
72
+ end
73
+
76
74
  end
@@ -137,25 +137,22 @@ describe 'Exchange' do
137
137
 
138
138
  it "should be able to return an undeliverable message" do
139
139
  exch = @b.exchange('return_exch')
140
- exch.publish('This message should be undeliverable', :immediate => true)
140
+ exch.publish('This message should be undeliverable', :mandatory => true)
141
141
  ret_msg = @b.returned_message
142
142
  ret_msg.should be_an_instance_of(Hash)
143
143
  ret_msg[:payload].should == 'This message should be undeliverable'
144
144
  end
145
145
 
146
- it "should be able to return a message that exceeds maximum frame size" do
146
+ it "should be able to handle connection close on trying to publish with immediate=true" do
147
147
  exch = @b.exchange('return_exch')
148
- lg_msg = 'z' * 142000
149
- exch.publish(lg_msg, :immediate => true)
150
- ret_msg = @b.returned_message
151
- ret_msg.should be_an_instance_of(Hash)
152
- ret_msg[:payload].should == lg_msg
148
+ exch.publish('This message should force a connection close', :immediate => true)
149
+ lambda { @b.returned_message }.should raise_error(Bunny::ForcedConnectionCloseError)
153
150
  end
154
151
 
155
- it "should report an error if delete fails" do
152
+ it "should not close the connection when trying to delete a non existent exchange" do
156
153
  exch = @b.exchange('direct_exchange')
157
- lambda { exch.delete(:exchange => 'bogus_ex') }.should raise_error(Bunny::ForcedChannelCloseError)
158
- @b.channel.active.should == false
154
+ exch.delete(:exchange => 'bogus_ex').should == :delete_ok
155
+ @b.channel.active.should == true
159
156
  end
160
157
 
161
158
  it "should be able to be deleted" do
@@ -61,10 +61,10 @@ describe 'Queue' do
61
61
  q.unbind(exch, :nowait => true).should == :unbind_ok
62
62
  end
63
63
 
64
- it "should raise an error if unbinding from a non-existent exchange" do
64
+ it "should not raise an error if unbinding from a non-existent exchange" do
65
65
  q = @b.queue('test1')
66
- lambda {q.unbind('bogus')}.should raise_error(Bunny::ForcedChannelCloseError)
67
- @b.channel.active.should == false
66
+ q.unbind('bogus').should == :unbind_ok
67
+ @b.channel.active.should == true
68
68
  end
69
69
 
70
70
  it "should be able to unbind from an exchange" do
@@ -155,10 +155,10 @@ describe 'Queue' do
155
155
  q.purge.should == :purge_ok
156
156
  end
157
157
 
158
- it "should raise an error when delete fails" do
158
+ it "should not close the connections when deleting a non existent queue" do
159
159
  q = @b.queue('test1')
160
- lambda {q.delete(:queue => 'bogus')}.should raise_error(Bunny::ForcedChannelCloseError)
161
- @b.channel.active.should == false
160
+ q.delete(:queue => 'bogus').should == :delete_ok
161
+ @b.channel.active.should == true
162
162
  end
163
163
 
164
164
  it "should pass correct block parameters through on subscribe" do
metadata CHANGED
@@ -1,15 +1,9 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 9
10
- version: 0.7.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.10
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Chris Duncan
14
8
  - Eric Lindvall
15
9
  - Jakub Stastny aka botanicus
@@ -18,28 +12,25 @@ authors:
18
12
  autorequire:
19
13
  bindir: bin
20
14
  cert_chain: []
21
-
22
- date: 2012-02-07 00:00:00 Z
15
+ date: 2015-07-15 00:00:00.000000000 Z
23
16
  dependencies: []
24
-
25
- description: A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers.
26
- email:
17
+ description: A synchronous Ruby AMQP client that enables interaction with AMQP-compliant
18
+ brokers.
19
+ email:
27
20
  - celldee@gmail.com
28
21
  - eric@5stops.com
29
22
  - stastny@101ideas.cz
30
23
  - michael@novemberain.com
31
24
  - skaes@railsexpress.de
32
25
  executables: []
33
-
34
26
  extensions: []
35
-
36
- extra_rdoc_files:
27
+ extra_rdoc_files:
37
28
  - README.textile
38
- files:
39
- - .gitignore
40
- - .rspec
41
- - .travis.yml
42
- - .yardopts
29
+ files:
30
+ - ".gitignore"
31
+ - ".rspec"
32
+ - ".travis.yml"
33
+ - ".yardopts"
43
34
  - CHANGELOG
44
35
  - Gemfile
45
36
  - LICENSE
@@ -105,39 +96,31 @@ files:
105
96
  - spec/spec_09/queue_spec.rb
106
97
  homepage: http://github.com/ruby-amqp/bunny
107
98
  licenses: []
108
-
109
- post_install_message: "[\e[32mVersion 0.7.8\e[0m] test suite cleanup (eliminated some race conditions related to queue.message_count)\n"
110
- rdoc_options:
111
- - --main
99
+ metadata: {}
100
+ post_install_message: "[\e[32mVersion 0.7.10\e[0m] handle messages larger than frame_max
101
+ correctly\n"
102
+ rdoc_options:
103
+ - "--main"
112
104
  - README.rdoc
113
- require_paths:
105
+ require_paths:
114
106
  - lib
115
- required_ruby_version: !ruby/object:Gem::Requirement
116
- none: false
117
- requirements:
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
118
109
  - - ">="
119
- - !ruby/object:Gem::Version
120
- hash: 3
121
- segments:
122
- - 0
123
- version: "0"
124
- required_rubygems_version: !ruby/object:Gem::Requirement
125
- none: false
126
- requirements:
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
127
114
  - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: 3
130
- segments:
131
- - 0
132
- version: "0"
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
133
117
  requirements: []
134
-
135
118
  rubyforge_project: bunny-amqp
136
- rubygems_version: 1.8.10
119
+ rubygems_version: 2.4.8
137
120
  signing_key:
138
- specification_version: 3
121
+ specification_version: 4
139
122
  summary: Synchronous Ruby AMQP 0.9.1 client
140
- test_files:
123
+ test_files:
141
124
  - spec/spec_08/bunny_spec.rb
142
125
  - spec/spec_08/connection_spec.rb
143
126
  - spec/spec_08/exchange_spec.rb
@@ -147,3 +130,4 @@ test_files:
147
130
  - spec/spec_09/connection_spec.rb
148
131
  - spec/spec_09/exchange_spec.rb
149
132
  - spec/spec_09/queue_spec.rb
133
+ has_rdoc: true