bunny 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e5fc526781ca58758094abdb97f80c73dbbd895
4
- data.tar.gz: 776c3e93dd301774054da7ac4a99969559a4efdc
3
+ metadata.gz: deafec372105c91a09a6d8b591586e30e4249130
4
+ data.tar.gz: a1cd14563b4cae9f215b0e0281ef593e671c874c
5
5
  SHA512:
6
- metadata.gz: 207adf5c0274c4277ab0c5a685188392d7f436b89bdec8101e98be513947ec44b8f560c8a0a190aad99de0787c5386b2757cc097f6de1453f41cdb9306f5ce77
7
- data.tar.gz: 4c20d9682bd762032fd3ca4b975b2c64096166c1b4ed863a364d41648a94b52d59332f016d96ab3e0e3aeb93b210ce403e7196e9348b25f59ed29b64697a074a
6
+ metadata.gz: 1c6aeff5a3446e1e183ea85eb665d710a583c69c9f0c63bb6eb0fd88799efc996d106cf594bd7daec645bc81c29f2f2fe7ac7c5788399d8191969813d2a52595
7
+ data.tar.gz: d951ff5afc82912a0aecf6076d8268c1ff14ec7e9a6ecc08cb0d40e5726edffcc7326a7fe73cc56c12b6169dedb9184cd0c2345d5ce823cd7879cb6cfa90488a
@@ -1,3 +1,21 @@
1
+ ## Changes between Bunny 0.9.1 and 0.9.2
2
+
3
+ ### Reliability Improvement in Automatic Network Failure Recovery
4
+
5
+ Bunny now ensures a new connection transport (socket) is initialized
6
+ before any recovery is attempted.
7
+
8
+
9
+
10
+ ## Changes between Bunny 0.9.0 and 0.9.1
11
+
12
+ ### Reliability Improvement in Bunny::Session#create_channel
13
+
14
+ `Bunny::Session#create_channel` now uses two separate mutexes to avoid
15
+ a (very rare) issue when the previous implementation would try to
16
+ re-acquire the same mutex and fail (Ruby mutexes are non-reentrant).
17
+
18
+
1
19
  ## Changes between Bunny 0.9.0.rc1 and 0.9.0.rc2
2
20
 
3
21
  ### Channel Now Properly Restarts Consumer Pool
@@ -151,8 +151,9 @@ module Bunny
151
151
  @transport_mutex = Mutex.new
152
152
  @channels = Hash.new
153
153
 
154
- self.reset_continuations
154
+ @origin_thread = Thread.current
155
155
 
156
+ self.reset_continuations
156
157
  self.initialize_transport
157
158
  end
158
159
 
@@ -485,7 +486,8 @@ module Bunny
485
486
  begin
486
487
  sleep @network_recovery_interval
487
488
  @logger.debug "About to start connection recovery..."
488
- start
489
+ self.initialize_transport
490
+ self.start
489
491
 
490
492
  if open?
491
493
  @recovering_from_network_failure = false
@@ -796,7 +798,7 @@ module Bunny
796
798
 
797
799
  # @private
798
800
  def initialize_transport
799
- @transport = Transport.new(self, @host, @port, @opts.merge(:session_thread => Thread.current))
801
+ @transport = Transport.new(self, @host, @port, @opts.merge(:session_thread => @origin_thread))
800
802
  end
801
803
 
802
804
  # @private
@@ -33,6 +33,7 @@ module Bunny
33
33
  @port = port
34
34
  @opts = opts
35
35
 
36
+ @logger = session.logger
36
37
  @tls_enabled = tls_enabled?(opts)
37
38
  @tls_certificate_path = tls_certificate_path_from(opts)
38
39
  @tls_key_path = tls_key_path_from(opts)
@@ -115,6 +116,7 @@ module Bunny
115
116
  end
116
117
  end
117
118
  rescue SystemCallError, Bunny::ClientTimeout, Bunny::ConnectionError, IOError => e
119
+ @logger.error "Got an exception when sending data: #{e.message} (#{e.class.name})"
118
120
  close
119
121
  @status = :not_connected
120
122
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "0.9.1"
5
+ VERSION = "0.9.2"
6
6
  end
@@ -61,10 +61,10 @@ describe Bunny::Consumer, "#cancel" do
61
61
  q.subscribe_with(consumer, :block => false)
62
62
  end
63
63
  t.abort_on_exception = true
64
- sleep 0.5
64
+ sleep 1.0
65
65
 
66
66
  consumer.cancel
67
- sleep 0.5
67
+ sleep 1.0
68
68
 
69
69
  ch = connection.create_channel
70
70
  ch.default_exchange.publish("", :routing_key => queue_name)
@@ -54,115 +54,108 @@ describe Bunny::Session do
54
54
 
55
55
 
56
56
  context "initialized with all defaults" do
57
- after :each do
58
- subject.close if subject.open?
59
- end
60
-
61
- subject do
62
- Bunny.new
63
- end
64
-
65
57
  it "provides a way to fine tune socket options" do
66
- subject.start
67
- subject.transport.socket.should respond_to(:setsockopt)
58
+ conn = Bunny.new
59
+ conn.start
60
+ conn.transport.socket.should respond_to(:setsockopt)
61
+
62
+ conn.close
68
63
  end
69
64
 
70
65
  it "successfully negotiates the connection" do
71
- subject.start
72
- subject.should be_connected
66
+ conn = Bunny.new
67
+ conn.start
68
+ conn.should be_connected
73
69
 
74
- subject.server_properties.should_not be_nil
75
- subject.server_capabilities.should_not be_nil
70
+ conn.server_properties.should_not be_nil
71
+ conn.server_capabilities.should_not be_nil
76
72
 
77
- props = subject.server_properties
73
+ props = conn.server_properties
78
74
 
79
75
  props["product"].should_not be_nil
80
76
  props["platform"].should_not be_nil
81
77
  props["version"].should_not be_nil
82
- end
83
- end
84
78
 
85
- context "initialized with TCP connection timeout = 5" do
86
- after :each do
87
- subject.close if subject.open?
79
+ conn.close
88
80
  end
81
+ end
89
82
 
90
- subject do
91
- described_class.new(:connection_timeout => 5)
92
- end
83
+ unless ENV["CI"]
84
+ context "initialized with TCP connection timeout = 5" do
85
+ it "successfully connects" do
86
+ conn = described_class.new(:connection_timeout => 5)
87
+ conn.start
88
+ conn.should be_connected
93
89
 
94
- it "successfully connects" do
95
- subject.start
96
- subject.should be_connected
90
+ conn.server_properties.should_not be_nil
91
+ conn.server_capabilities.should_not be_nil
97
92
 
98
- subject.server_properties.should_not be_nil
99
- subject.server_capabilities.should_not be_nil
93
+ props = conn.server_properties
100
94
 
101
- props = subject.server_properties
95
+ props["product"].should_not be_nil
96
+ props["platform"].should_not be_nil
97
+ props["version"].should_not be_nil
102
98
 
103
- props["product"].should_not be_nil
104
- props["platform"].should_not be_nil
105
- props["version"].should_not be_nil
99
+ conn.close
100
+ end
106
101
  end
107
- end
108
102
 
109
- context "initialized with :host => 127.0.0.1" do
110
- after :each do
111
- subject.close if subject.open?
112
- end
103
+ context "initialized with :host => 127.0.0.1" do
104
+ after :each do
105
+ subject.close if subject.open?
106
+ end
113
107
 
114
- let(:host) { "127.0.0.1" }
115
- subject do
116
- described_class.new(:host => host)
117
- end
108
+ let(:host) { "127.0.0.1" }
109
+ subject do
110
+ described_class.new(:host => host)
111
+ end
118
112
 
119
- it "uses hostname = 127.0.0.1" do
120
- subject.host.should == host
121
- subject.hostname.should == host
122
- end
113
+ it "uses hostname = 127.0.0.1" do
114
+ subject.host.should == host
115
+ subject.hostname.should == host
116
+ end
123
117
 
124
- it "uses port 5672" do
125
- subject.port.should == port
126
- end
118
+ it "uses port 5672" do
119
+ subject.port.should == port
120
+ end
127
121
 
128
- it "uses username = guest" do
129
- subject.username.should == username
122
+ it "uses username = guest" do
123
+ subject.username.should == username
124
+ end
130
125
  end
131
- end
132
126
 
133
- context "initialized with :hostname => localhost" do
134
- after :each do
135
- subject.close if subject.open?
136
- end
127
+ context "initialized with :hostname => localhost" do
128
+ after :each do
129
+ subject.close if subject.open?
130
+ end
137
131
 
138
- let(:host) { "localhost" }
139
- let(:subject) { described_class.new(:hostname => host) }
132
+ let(:host) { "localhost" }
133
+ let(:subject) { described_class.new(:hostname => host) }
140
134
 
141
- it "uses hostname = localhost" do
142
- subject.host.should == host
143
- subject.hostname.should == host
144
- end
135
+ it "uses hostname = localhost" do
136
+ subject.host.should == host
137
+ subject.hostname.should == host
138
+ end
145
139
 
146
- it "uses port 5672" do
147
- subject.port.should == port
148
- end
140
+ it "uses port 5672" do
141
+ subject.port.should == port
142
+ end
149
143
 
150
- it "uses username = guest" do
151
- subject.username.should == username
152
- subject.user.should == username
144
+ it "uses username = guest" do
145
+ subject.username.should == username
146
+ subject.user.should == username
147
+ end
153
148
  end
154
- end
155
149
 
156
- unless ENV["CI"]
157
150
  context "initialized with :ssl => true" do
158
151
  let(:subject) do
159
152
  described_class.new(:user => "bunny_gem",
160
- :password => "bunny_password",
161
- :vhost => "bunny_testbed",
162
- :ssl => true,
163
- :ssl_cert => "spec/tls/client_cert.pem",
164
- :ssl_key => "spec/tls/client_key.pem",
165
- :ssl_ca_certificates => ["./spec/tls/cacert.pem"])
153
+ :password => "bunny_password",
154
+ :vhost => "bunny_testbed",
155
+ :ssl => true,
156
+ :ssl_cert => "spec/tls/client_cert.pem",
157
+ :ssl_key => "spec/tls/client_key.pem",
158
+ :ssl_ca_certificates => ["./spec/tls/cacert.pem"])
166
159
  end
167
160
 
168
161
  it "uses TLS port" do
@@ -173,12 +166,12 @@ describe Bunny::Session do
173
166
  context "initialized with :tls => true" do
174
167
  let(:subject) do
175
168
  described_class.new(:user => "bunny_gem",
176
- :password => "bunny_password",
177
- :vhost => "bunny_testbed",
178
- :tls => true,
179
- :tls_cert => "spec/tls/client_cert.pem",
180
- :tls_key => "spec/tls/client_key.pem",
181
- :tls_ca_certificates => ["./spec/tls/cacert.pem"])
169
+ :password => "bunny_password",
170
+ :vhost => "bunny_testbed",
171
+ :tls => true,
172
+ :tls_cert => "spec/tls/client_cert.pem",
173
+ :tls_key => "spec/tls/client_key.pem",
174
+ :tls_ca_certificates => ["./spec/tls/cacert.pem"])
182
175
  end
183
176
 
184
177
  it "uses TLS port" do
@@ -7,10 +7,11 @@ describe Bunny::Channel do
7
7
  c
8
8
  end
9
9
 
10
- after :all do
10
+ after :each do
11
11
  connection.close if connection.open?
12
12
  end
13
13
 
14
+ let(:n) { 200 }
14
15
 
15
16
  context "when publishing with confirms enabled" do
16
17
  it "increments delivery index" do
@@ -23,15 +24,15 @@ describe Bunny::Channel do
23
24
  q = ch.queue("", :exclusive => true)
24
25
  x = ch.default_exchange
25
26
 
26
- 500.times do
27
+ n.times do
27
28
  x.publish("xyzzy", :routing_key => q.name)
28
29
  end
29
30
 
30
- ch.next_publish_seq_no.should == 501
31
+ ch.next_publish_seq_no.should == n + 1
31
32
  ch.wait_for_confirms.should be_true
32
33
  sleep 0.25
33
34
 
34
- q.message_count.should == 500
35
+ q.message_count.should == n
35
36
  q.purge
36
37
 
37
38
  ch.close
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-07-17 00:00:00.000000000 Z
15
+ date: 2013-07-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
@@ -181,7 +181,6 @@ files:
181
181
  - spec/unit/bunny_spec.rb
182
182
  - spec/unit/concurrent/condition_spec.rb
183
183
  - spec/unit/concurrent/linked_continuation_queue_spec.rb
184
- - spec/unit/transport_spec.rb
185
184
  homepage: http://rubybunny.info
186
185
  licenses:
187
186
  - MIT
@@ -202,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
201
  version: '0'
203
202
  requirements: []
204
203
  rubyforge_project:
205
- rubygems_version: 2.0.3
204
+ rubygems_version: 2.0.5
206
205
  signing_key:
207
206
  specification_version: 4
208
207
  summary: Popular easy to use Ruby client for RabbitMQ
@@ -268,5 +267,4 @@ test_files:
268
267
  - spec/unit/bunny_spec.rb
269
268
  - spec/unit/concurrent/condition_spec.rb
270
269
  - spec/unit/concurrent/linked_continuation_queue_spec.rb
271
- - spec/unit/transport_spec.rb
272
270
  has_rdoc: true
@@ -1,18 +0,0 @@
1
- require "spec_helper"
2
-
3
- # mystically fails on Rubinius on CI. MK.
4
- if RUBY_ENGINE != "rbx"
5
- describe Bunny::Transport, ".reachable?" do
6
- it "returns true for google.com, 80" do
7
- Bunny::Transport.reacheable?("google.com", 80, 1).should be_true
8
- end
9
-
10
- it "returns true for google.com, 8088" do
11
- Bunny::Transport.reacheable?("google.com", 8088, 1).should be_false
12
- end
13
-
14
- it "returns false for google1237982792837.com, 8277" do
15
- Bunny::Transport.reacheable?("google1237982792837.com", 8277, 1).should be_false
16
- end
17
- end
18
- end