bunny 2.14.2 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -6
- data/ChangeLog.md +67 -10
- data/Gemfile +2 -2
- data/README.md +5 -6
- data/bunny.gemspec +4 -4
- data/docker/Dockerfile +8 -4
- data/docker/docker-entrypoint.sh +2 -2
- data/lib/bunny/channel.rb +1 -1
- data/lib/bunny/cruby/socket.rb +3 -0
- data/lib/bunny/queue.rb +0 -3
- data/lib/bunny/reader_loop.rb +21 -13
- data/lib/bunny/session.rb +23 -6
- data/lib/bunny/transport.rb +5 -5
- data/lib/bunny/version.rb +1 -1
- data/repl +1 -1
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +4 -4
- data/spec/higher_level_api/integration/basic_consume_spec.rb +3 -3
- data/spec/higher_level_api/integration/connection_spec.rb +26 -0
- data/spec/higher_level_api/integration/tls_connection_spec.rb +201 -189
- data/spec/issues/issue202_spec.rb +1 -1
- data/spec/issues/issue78_spec.rb +2 -2
- data/spec/unit/exchange_recovery_spec.rb +2 -2
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3ba4a5565a42eace00f8789c1be953871d9dc57d42028a94a9dd70a586271e
|
4
|
+
data.tar.gz: c7d2fdf832b466a27c7ae884e6195729d31a6bf1cb6accde9818c2f72b46cdc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26a352492ca652429975e45ec36fad12ebfd3c94e66babb879afb0f09dcec0158affc820f8a29fd07a25d8db6ac9312fd31ebc5b1a3d4c315ecfeeb880a5a8f2
|
7
|
+
data.tar.gz: 393fa99fb87c7784eccd0f5019fe3668b39064e15935d85f4134c85aa6b138849d0026addb814f49d00f606b9157b78878863c875d2ad6480b17b3053dcb98fb
|
data/.travis.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
dist: bionic
|
1
2
|
language: ruby
|
2
3
|
bundler_args: --without development
|
3
4
|
cache: bundler
|
@@ -10,10 +11,11 @@ before_script:
|
|
10
11
|
script: "bundle exec rake integration_without_recovery"
|
11
12
|
rvm:
|
12
13
|
- ruby-head
|
13
|
-
- "2.
|
14
|
-
- "2.
|
15
|
-
- "2.
|
16
|
-
- "2.
|
14
|
+
- "2.7.1"
|
15
|
+
- "2.6.6"
|
16
|
+
- "2.5.8"
|
17
|
+
- "2.4.10"
|
18
|
+
- "2.3.8"
|
17
19
|
notifications:
|
18
20
|
email: michael@rabbitmq.com
|
19
21
|
services:
|
@@ -21,8 +23,8 @@ services:
|
|
21
23
|
branches:
|
22
24
|
only:
|
23
25
|
- master
|
24
|
-
- 2.
|
25
|
-
- 2.
|
26
|
+
- 2.14.x-stable
|
27
|
+
- 2.13.x-stable
|
26
28
|
env:
|
27
29
|
- CI=true
|
28
30
|
matrix:
|
data/ChangeLog.md
CHANGED
@@ -1,22 +1,70 @@
|
|
1
|
-
## Changes between Bunny 2.
|
1
|
+
## Changes between Bunny 2.17.x and 2.18.0 (in development)
|
2
2
|
|
3
3
|
No changes yet.
|
4
4
|
|
5
5
|
|
6
|
-
## Changes between Bunny 2.
|
6
|
+
## Changes between Bunny 2.16.x and 2.17.0 (Sep 11th, 2020)
|
7
7
|
|
8
|
-
###
|
8
|
+
### Easier to Specify a Client-Propvided Connection Name
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
It is now easier to provide a client-provided (custom) connection
|
11
|
+
name that will be displayed in the RabbitMQ management UI and mentioned in
|
12
|
+
[server logs](https://www.rabbitmq.com/logging.html).
|
13
13
|
|
14
|
-
|
14
|
+
Instead of
|
15
15
|
|
16
|
-
|
16
|
+
``` ruby
|
17
|
+
conn = Bunny.new(client_properties: {connection_name: 'app ABC #{rand}'})
|
18
|
+
conn.start
|
19
|
+
```
|
20
|
+
|
21
|
+
a new top-level connection option now can be used:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
conn = Bunny.new(connection_name: 'app ABC #{rand}')
|
25
|
+
conn.start
|
26
|
+
```
|
27
|
+
|
28
|
+
Contributed by @brerx.
|
29
|
+
|
30
|
+
GitHub issue: [ruby-amqp/bunny#600](https://github.com/ruby-amqp/bunny/pull/600)
|
31
|
+
|
32
|
+
|
33
|
+
## Changes between Bunny 2.15.0 and 2.16.0 (Aug 14th, 2020)
|
34
|
+
|
35
|
+
### Asynchronous Exception Delegate
|
36
|
+
|
37
|
+
Bunny now can delete asynchronous connection (`Bunny::Session`) exception to an arbitrary
|
38
|
+
delegate object. Use the `:session_error_handler` connection setting to pass it.
|
39
|
+
The value defaults to `Thread.current`.
|
17
40
|
|
41
|
+
Contributed by @bbascarevic.
|
18
42
|
|
19
|
-
|
43
|
+
GitHub issue: [ruby-amqp/bunny#597](https://github.com/ruby-amqp/bunny/issues/597)
|
44
|
+
|
45
|
+
|
46
|
+
## Changes between Bunny 2.14.0 and 2.15.0 (Apr 8th, 2020)
|
47
|
+
|
48
|
+
### More Defensive Thread Join Operations
|
49
|
+
|
50
|
+
Bunny is now more defensive around thread join operations which it performs
|
51
|
+
when stopping its consumer work pool.
|
52
|
+
|
53
|
+
`Thread#join` can cause an unhandled exception to be re-raised at
|
54
|
+
a very surprising moment. This behavior can also be affected by 3rd party
|
55
|
+
libraries, e.g. those that do connection pooling. While Bunny cannot
|
56
|
+
fully avoid every possible surprising failure, it now avoids at least
|
57
|
+
one such problematic interaction triggered by a custom [interrupt handler](https://ruby-doc.org/core-2.5.1/Thread.html#method-c-handle_interrupt)
|
58
|
+
in a 3rd party library.
|
59
|
+
|
60
|
+
GitHub issue: [#589](https://github.com/ruby-amqp/bunny/issues/589)
|
61
|
+
|
62
|
+
Contributed by @fuegas.
|
63
|
+
|
64
|
+
### Dependency Updates
|
65
|
+
|
66
|
+
`amq-protocol` dependency has been bumped to `2.3.1` to support `connection.update-secret`
|
67
|
+
protocol extension.
|
20
68
|
|
21
69
|
### Gem Installation Fixed on Windows
|
22
70
|
|
@@ -24,7 +72,16 @@ Contributed by Garrett Thornburg.
|
|
24
72
|
|
25
73
|
Contributed by Jack Xiaosong Xu.
|
26
74
|
|
27
|
-
|
75
|
+
### Lazy Peer Certificate Chain Information Logging
|
76
|
+
|
77
|
+
Peer certificate chain information is now logged lazily, which prevents
|
78
|
+
an obscure exception originating ASN.1 parser and makes the logging
|
79
|
+
code evaluate only when it is really necessary.
|
80
|
+
|
81
|
+
GitHub issue: [#578](https://github.com/ruby-amqp/bunny/pull/578)
|
82
|
+
|
83
|
+
Contributed by Garrett Thornburg.
|
84
|
+
|
28
85
|
|
29
86
|
## Changes between Bunny 2.13.0 and 2.14.0 (Feb 20th, 2019)
|
30
87
|
|
data/Gemfile
CHANGED
@@ -33,8 +33,8 @@ group :development do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
group :test do
|
36
|
-
gem "rspec", "~> 3.
|
37
|
-
gem "rabbitmq_http_api_client", "~> 1.
|
36
|
+
gem "rspec", "~> 3.9.0"
|
37
|
+
gem "rabbitmq_http_api_client", "~> 1.13.0", require: "rabbitmq/http/client"
|
38
38
|
gem "toxiproxy", "~> 1.0.3"
|
39
39
|
end
|
40
40
|
|
data/README.md
CHANGED
@@ -43,12 +43,11 @@ Specific examples:
|
|
43
43
|
Web applications that display that information in the real time.
|
44
44
|
|
45
45
|
|
46
|
-
|
47
46
|
## Supported Ruby Versions
|
48
47
|
|
49
48
|
Modern Bunny versions support
|
50
49
|
|
51
|
-
* CRuby 2.
|
50
|
+
* CRuby 2.3 through 2.7 (inclusive)
|
52
51
|
|
53
52
|
Bunny works sufficiently well on JRuby but there are known
|
54
53
|
JRuby bugs in versions prior to JRuby 9000 that cause high CPU burn. JRuby users should
|
@@ -71,10 +70,10 @@ a stable public API.
|
|
71
70
|
Change logs per release series:
|
72
71
|
|
73
72
|
* [master](https://github.com/ruby-amqp/bunny/blob/master/ChangeLog.md)
|
73
|
+
* [2.16.x](https://github.com/ruby-amqp/bunny/blob/2.16.x-stable/ChangeLog.md)
|
74
|
+
* [2.15.x](https://github.com/ruby-amqp/bunny/blob/2.15.x-stable/ChangeLog.md)
|
75
|
+
* [2.14.x](https://github.com/ruby-amqp/bunny/blob/2.14.x-stable/ChangeLog.md)
|
74
76
|
* [2.13.x](https://github.com/ruby-amqp/bunny/blob/2.13.x-stable/ChangeLog.md)
|
75
|
-
* [2.12.x](https://github.com/ruby-amqp/bunny/blob/2.12.x-stable/ChangeLog.md)
|
76
|
-
* [2.11.x](https://github.com/ruby-amqp/bunny/blob/2.11.x-stable/ChangeLog.md)
|
77
|
-
* [2.10.x](https://github.com/ruby-amqp/bunny/blob/2.10.x-stable/ChangeLog.md)
|
78
77
|
|
79
78
|
|
80
79
|
|
@@ -97,7 +96,7 @@ gem install bunny
|
|
97
96
|
To use Bunny in a project managed with Bundler:
|
98
97
|
|
99
98
|
``` ruby
|
100
|
-
gem "bunny", ">= 2.
|
99
|
+
gem "bunny", ">= 2.16.1"
|
101
100
|
```
|
102
101
|
|
103
102
|
|
data/bunny.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.name = "bunny"
|
9
9
|
s.version = Bunny::VERSION.dup
|
10
10
|
s.homepage = "http://rubybunny.info"
|
11
|
-
s.summary = "
|
12
|
-
s.description = "Easy to use, feature complete Ruby client for RabbitMQ"
|
11
|
+
s.summary = "Popular easy to use Ruby client for RabbitMQ"
|
12
|
+
s.description = "Easy to use, feature complete Ruby client for RabbitMQ 3.3 and later versions."
|
13
13
|
s.license = "MIT"
|
14
14
|
s.required_ruby_version = Gem::Requirement.new(">= 2.2")
|
15
15
|
|
@@ -21,10 +21,10 @@ Gem::Specification.new do |s|
|
|
21
21
|
"Michael S. Klishin",
|
22
22
|
"Stefan Kaes"]
|
23
23
|
|
24
|
-
s.email = ["
|
24
|
+
s.email = ["michael.s.klishin@gmail.com"]
|
25
25
|
|
26
26
|
# Dependencies
|
27
|
-
s.add_runtime_dependency 'amq-protocol', '~> 2.3', '>= 2.3.
|
27
|
+
s.add_runtime_dependency 'amq-protocol', '~> 2.3', '>= 2.3.1'
|
28
28
|
|
29
29
|
# Files.
|
30
30
|
s.extra_rdoc_files = ["README.md"]
|
data/docker/Dockerfile
CHANGED
@@ -7,11 +7,15 @@ RUN wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/ra
|
|
7
7
|
COPY apt/sources.list.d/bintray.rabbitmq.list /etc/apt/sources.list.d/bintray.rabbitmq.list
|
8
8
|
COPY apt/preferences.d/erlang /etc/apt/preferences.d/erlang
|
9
9
|
|
10
|
-
RUN apt-get update -y
|
10
|
+
RUN apt-get update -y && apt-get upgrade -y
|
11
|
+
|
12
|
+
RUN apt-get install -y erlang-base \
|
13
|
+
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
|
14
|
+
erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
|
15
|
+
erlang-runtime-tools erlang-snmp erlang-ssl \
|
16
|
+
erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl
|
11
17
|
|
12
|
-
RUN apt-get
|
13
|
-
apt-get install -y erlang-asn1 erlang-crypto erlang-public-key erlang-ssl && \
|
14
|
-
apt-get install -y rabbitmq-server
|
18
|
+
RUN apt-get install -y rabbitmq-server
|
15
19
|
|
16
20
|
COPY docker-entrypoint.sh /
|
17
21
|
|
data/docker/docker-entrypoint.sh
CHANGED
@@ -6,9 +6,9 @@ delay=5
|
|
6
6
|
echo 'Starting a RabbitMQ node'
|
7
7
|
$server -detached
|
8
8
|
|
9
|
-
echo "Waiting
|
9
|
+
echo "Waiting for RabbitMQ to finish startup..."
|
10
10
|
|
11
|
-
|
11
|
+
$ctl await_startup --timeout 15
|
12
12
|
|
13
13
|
$ctl add_user bunny_gem bunny_password
|
14
14
|
$ctl add_user bunny_reader reader_password
|
data/lib/bunny/channel.rb
CHANGED
@@ -1156,7 +1156,7 @@ module Bunny
|
|
1156
1156
|
|
1157
1157
|
# @group Exchange operations (exchange.*)
|
1158
1158
|
|
1159
|
-
# Declares a exchange using
|
1159
|
+
# Declares a exchange using exchange.declare AMQP 0.9.1 method.
|
1160
1160
|
#
|
1161
1161
|
# @param [String] name The name of the exchange. Note that LF and CR characters
|
1162
1162
|
# will be stripped from the value.
|
data/lib/bunny/cruby/socket.rb
CHANGED
@@ -32,6 +32,9 @@ module Bunny
|
|
32
32
|
socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, true)
|
33
33
|
end
|
34
34
|
socket.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_KEEPALIVE, true) if options.fetch(:keepalive, true)
|
35
|
+
socket.instance_eval do
|
36
|
+
@__bunny_socket_eof_flag__ = false
|
37
|
+
end
|
35
38
|
socket.extend self
|
36
39
|
socket.options = { :host => host, :port => port }.merge(options)
|
37
40
|
socket
|
data/lib/bunny/queue.rb
CHANGED
@@ -158,9 +158,6 @@ module Bunny
|
|
158
158
|
# @option opts [Boolean] :ack (false) [DEPRECATED] Use :manual_ack instead
|
159
159
|
# @option opts [Boolean] :manual_ack (false) Will this consumer use manual acknowledgements?
|
160
160
|
# @option opts [Boolean] :exclusive (false) Should this consumer be exclusive for this queue?
|
161
|
-
# @option opts [Boolean] :block (false) Should the call block the calling thread? This option can be useful for keeping the main thread of
|
162
|
-
# a script alive. It is incompatible with automatic connection recovery
|
163
|
-
# and is not generally recommended.
|
164
161
|
# @option opts [#call] :on_cancellation Block to execute when this consumer is cancelled remotely (e.g. via the RabbitMQ Management plugin)
|
165
162
|
# @option opts [String] :consumer_tag Unique consumer identifier. It is usually recommended to let Bunny generate it for you.
|
166
163
|
# @option opts [Hash] :arguments ({}) Additional (optional) arguments, typically used by RabbitMQ extensions
|
data/lib/bunny/reader_loop.rb
CHANGED
@@ -9,17 +9,17 @@ module Bunny
|
|
9
9
|
# @private
|
10
10
|
class ReaderLoop
|
11
11
|
|
12
|
-
def initialize(transport, session,
|
13
|
-
@transport
|
14
|
-
@session
|
15
|
-
@
|
16
|
-
@logger
|
12
|
+
def initialize(transport, session, session_error_handler)
|
13
|
+
@transport = transport
|
14
|
+
@session = session
|
15
|
+
@session_error_handler = session_error_handler
|
16
|
+
@logger = @session.logger
|
17
17
|
|
18
|
-
@mutex
|
18
|
+
@mutex = Mutex.new
|
19
19
|
|
20
|
-
@stopping
|
21
|
-
@stopped
|
22
|
-
@network_is_down
|
20
|
+
@stopping = false
|
21
|
+
@stopped = false
|
22
|
+
@network_is_down = false
|
23
23
|
end
|
24
24
|
|
25
25
|
|
@@ -37,7 +37,8 @@ module Bunny
|
|
37
37
|
begin
|
38
38
|
break if @mutex.synchronize { @stopping || @stopped || @network_is_down }
|
39
39
|
run_once
|
40
|
-
rescue AMQ::Protocol::EmptyResponseError, IOError, SystemCallError, Timeout::Error
|
40
|
+
rescue AMQ::Protocol::EmptyResponseError, IOError, SystemCallError, Timeout::Error,
|
41
|
+
OpenSSL::OpenSSLError => e
|
41
42
|
break if terminate? || @session.closing? || @session.closed?
|
42
43
|
|
43
44
|
@network_is_down = true
|
@@ -46,7 +47,7 @@ module Bunny
|
|
46
47
|
@session.handle_network_failure(e)
|
47
48
|
else
|
48
49
|
log_exception(e)
|
49
|
-
@
|
50
|
+
@session_error_handler.raise(Bunny::NetworkFailure.new("detected a network failure: #{e.message}", e))
|
50
51
|
end
|
51
52
|
rescue ShutdownSignal => _
|
52
53
|
@mutex.synchronize { @stopping = true }
|
@@ -57,7 +58,7 @@ module Bunny
|
|
57
58
|
log_exception(e)
|
58
59
|
|
59
60
|
@network_is_down = true
|
60
|
-
@
|
61
|
+
@session_error_handler.raise(Bunny::NetworkFailure.new("caught an unexpected exception in the network loop: #{e.message}", e))
|
61
62
|
end
|
62
63
|
rescue Errno::EBADF => _ebadf
|
63
64
|
break if terminate?
|
@@ -115,7 +116,14 @@ module Bunny
|
|
115
116
|
end
|
116
117
|
|
117
118
|
def join
|
118
|
-
|
119
|
+
# Thread#join can/would trigger a re-raise of an unhandled exception in this thread.
|
120
|
+
# In addition, Thread.handle_interrupt can be used by other libraries or application code
|
121
|
+
# that would make this join operation fail with an obscure exception.
|
122
|
+
# So we try to save everyone some really unpleasant debugging time by introducing
|
123
|
+
# this condition which typically would not evaluate to true anyway.
|
124
|
+
#
|
125
|
+
# See ruby-amqp/bunny#589 and ruby-amqp/bunny#590 for background.
|
126
|
+
@thread.join if @thread && @thread != Thread.current
|
119
127
|
end
|
120
128
|
|
121
129
|
def kill
|
data/lib/bunny/session.rb
CHANGED
@@ -89,6 +89,7 @@ module Bunny
|
|
89
89
|
# @return [Integer] Timeout for blocking protocol operations (queue.declare, queue.bind, etc), in milliseconds. Default is 15000.
|
90
90
|
attr_reader :continuation_timeout
|
91
91
|
attr_reader :network_recovery_interval
|
92
|
+
attr_reader :connection_name
|
92
93
|
attr_accessor :socket_configurator
|
93
94
|
|
94
95
|
# @param [String, Hash] connection_string_or_opts Connection string or a hash of connection options
|
@@ -124,9 +125,11 @@ module Bunny
|
|
124
125
|
# @option connection_string_or_opts [Integer] :recovery_attempts (nil) Max number of recovery attempts, nil means forever
|
125
126
|
# @option connection_string_or_opts [Integer] :reset_recovery_attempts_after_reconnection (true) Should recovery attempt counter be reset after successful reconnection? When set to false, the attempt counter will last through the entire lifetime of the connection object.
|
126
127
|
# @option connection_string_or_opts [Boolean] :recover_from_connection_close (true) Should this connection recover after receiving a server-sent connection.close (e.g. connection was force closed)?
|
128
|
+
# @option connection_string_or_opts [Object] :session_error_handler (Thread.current) Object which responds to #raise that will act as a session error handler. Defaults to Thread.current, which will raise asynchronous exceptions in the thread that created the session.
|
127
129
|
#
|
128
130
|
# @option optz [String] :auth_mechanism ("PLAIN") Authentication mechanism, PLAIN or EXTERNAL
|
129
131
|
# @option optz [String] :locale ("PLAIN") Locale RabbitMQ should use
|
132
|
+
# @option optz [String] :connection_name (nil) Client-provided connection name, if any. Note that the value returned does not uniquely identify a connection and cannot be used as a connection identifier in HTTP API requests.
|
130
133
|
#
|
131
134
|
# @see http://rubybunny.info/articles/connecting.html Connecting to RabbitMQ guide
|
132
135
|
# @see http://rubybunny.info/articles/tls.html TLS/SSL guide
|
@@ -171,6 +174,7 @@ module Bunny
|
|
171
174
|
else
|
172
175
|
opts[:automatically_recover] || opts[:automatic_recovery]
|
173
176
|
end
|
177
|
+
@recovering_from_network_failure = false
|
174
178
|
@max_recovery_attempts = opts[:recovery_attempts]
|
175
179
|
@recovery_attempts = @max_recovery_attempts
|
176
180
|
# When this is set, connection attempts won't be reset after
|
@@ -184,6 +188,7 @@ module Bunny
|
|
184
188
|
@continuation_timeout = opts.fetch(:continuation_timeout, DEFAULT_CONTINUATION_TIMEOUT)
|
185
189
|
|
186
190
|
@status = :not_connected
|
191
|
+
@manually_closed = false
|
187
192
|
@blocked = false
|
188
193
|
|
189
194
|
# these are negotiated with the broker during the connection tuning phase
|
@@ -195,7 +200,9 @@ module Bunny
|
|
195
200
|
@client_heartbeat = self.heartbeat_from(opts)
|
196
201
|
|
197
202
|
client_props = opts[:properties] || opts[:client_properties] || {}
|
203
|
+
@connection_name = client_props[:connection_name] || opts[:connection_name]
|
198
204
|
@client_properties = DEFAULT_CLIENT_PROPERTIES.merge(client_props)
|
205
|
+
.merge(connection_name: connection_name)
|
199
206
|
@mechanism = normalize_auth_mechanism(opts.fetch(:auth_mechanism, "PLAIN"))
|
200
207
|
@credentials_encoder = credentials_encoder_for(@mechanism)
|
201
208
|
@locale = @opts.fetch(:locale, DEFAULT_LOCALE)
|
@@ -211,9 +218,9 @@ module Bunny
|
|
211
218
|
@address_index_mutex = @mutex_impl.new
|
212
219
|
|
213
220
|
@channels = Hash.new
|
214
|
-
@recovery_completed
|
221
|
+
@recovery_completed = opts[:recovery_completed]
|
215
222
|
|
216
|
-
@
|
223
|
+
@session_error_handler = opts.fetch(:session_error_handler, Thread.current)
|
217
224
|
|
218
225
|
self.reset_continuations
|
219
226
|
self.initialize_transport
|
@@ -340,6 +347,14 @@ module Bunny
|
|
340
347
|
self
|
341
348
|
end
|
342
349
|
|
350
|
+
def update_secret(value, reason)
|
351
|
+
@transport.send_frame(AMQ::Protocol::Connection::UpdateSecret.encode(value, reason))
|
352
|
+
@last_update_secret_ok = wait_on_continuations
|
353
|
+
raise_if_continuation_resulted_in_a_connection_error!
|
354
|
+
|
355
|
+
@last_update_secret_ok
|
356
|
+
end
|
357
|
+
|
343
358
|
# Socket operation write timeout used by this connection
|
344
359
|
# @return [Integer]
|
345
360
|
# @private
|
@@ -630,6 +645,8 @@ module Bunny
|
|
630
645
|
when AMQ::Protocol::Connection::Unblocked then
|
631
646
|
@blocked = false
|
632
647
|
@unblock_callback.call(method) if @unblock_callback
|
648
|
+
when AMQ::Protocol::Connection::UpdateSecretOk then
|
649
|
+
@continuations.push(method)
|
633
650
|
when AMQ::Protocol::Channel::Close then
|
634
651
|
begin
|
635
652
|
ch = synchronised_find_channel(ch_number)
|
@@ -850,7 +867,7 @@ module Bunny
|
|
850
867
|
|
851
868
|
clean_up_on_shutdown
|
852
869
|
if threaded?
|
853
|
-
@
|
870
|
+
@session_error_handler.raise(@last_connection_error)
|
854
871
|
else
|
855
872
|
raise @last_connection_error
|
856
873
|
end
|
@@ -1007,7 +1024,7 @@ module Bunny
|
|
1007
1024
|
|
1008
1025
|
# @private
|
1009
1026
|
def reader_loop
|
1010
|
-
@reader_loop ||= ReaderLoop.new(@transport, self,
|
1027
|
+
@reader_loop ||= ReaderLoop.new(@transport, self, @session_error_handler)
|
1011
1028
|
end
|
1012
1029
|
|
1013
1030
|
# @private
|
@@ -1270,7 +1287,7 @@ module Bunny
|
|
1270
1287
|
end
|
1271
1288
|
|
1272
1289
|
if threaded?
|
1273
|
-
@
|
1290
|
+
@session_error_handler.raise(e)
|
1274
1291
|
else
|
1275
1292
|
raise e
|
1276
1293
|
end
|
@@ -1316,7 +1333,7 @@ module Bunny
|
|
1316
1333
|
@transport = Transport.new(self,
|
1317
1334
|
host_from_address(address),
|
1318
1335
|
port_from_address(address),
|
1319
|
-
@opts.merge(:
|
1336
|
+
@opts.merge(:session_error_handler => @session_error_handler)
|
1320
1337
|
)
|
1321
1338
|
|
1322
1339
|
# Reset the cached progname for the logger only when no logger was provided
|
data/lib/bunny/transport.rb
CHANGED
@@ -35,7 +35,7 @@ module Bunny
|
|
35
35
|
|
36
36
|
def initialize(session, host, port, opts)
|
37
37
|
@session = session
|
38
|
-
@
|
38
|
+
@session_error_handler = opts[:session_error_handler]
|
39
39
|
@host = host
|
40
40
|
@port = port
|
41
41
|
@opts = opts
|
@@ -146,7 +146,7 @@ module Bunny
|
|
146
146
|
if @session.automatically_recover?
|
147
147
|
@session.handle_network_failure(e)
|
148
148
|
else
|
149
|
-
@
|
149
|
+
@session_error_handler.raise(Bunny::NetworkFailure.new("detected a network failure: #{e.message}", e))
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
@@ -170,7 +170,7 @@ module Bunny
|
|
170
170
|
if @session.automatically_recover?
|
171
171
|
@session.handle_network_failure(e)
|
172
172
|
else
|
173
|
-
@
|
173
|
+
@session_error_handler.raise(Bunny::NetworkFailure.new("detected a network failure: #{e.message}", e))
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
@@ -188,7 +188,7 @@ module Bunny
|
|
188
188
|
if @session.automatically_recover?
|
189
189
|
@session.handle_network_failure(e)
|
190
190
|
else
|
191
|
-
@
|
191
|
+
@session_error_handler.raise(Bunny::NetworkFailure.new("detected a network failure: #{e.message}", e))
|
192
192
|
end
|
193
193
|
end
|
194
194
|
end
|
@@ -245,7 +245,7 @@ module Bunny
|
|
245
245
|
if @session.automatically_recover?
|
246
246
|
raise
|
247
247
|
else
|
248
|
-
@
|
248
|
+
@session_error_handler.raise(Bunny::NetworkFailure.new("detected a network failure: #{e.message}", e))
|
249
249
|
end
|
250
250
|
end
|
251
251
|
end
|
data/lib/bunny/version.rb
CHANGED
data/repl
CHANGED
@@ -20,7 +20,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
20
20
|
t = Thread.new do
|
21
21
|
ch = connection.create_channel
|
22
22
|
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
23
|
-
consumer = q.subscribe
|
23
|
+
consumer = q.subscribe do |_, _, payload|
|
24
24
|
delivered_data << payload
|
25
25
|
end
|
26
26
|
|
@@ -58,7 +58,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
58
58
|
delivered_data << payload
|
59
59
|
end
|
60
60
|
|
61
|
-
q.subscribe_with(consumer
|
61
|
+
q.subscribe_with(consumer)
|
62
62
|
end
|
63
63
|
t.abort_on_exception = true
|
64
64
|
sleep 1.0
|
@@ -91,7 +91,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
91
91
|
delivered_data << payload
|
92
92
|
end
|
93
93
|
|
94
|
-
q.subscribe_with(consumer
|
94
|
+
q.subscribe_with(consumer)
|
95
95
|
end
|
96
96
|
t.abort_on_exception = true
|
97
97
|
sleep 1.0
|
@@ -122,7 +122,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
122
122
|
delivered_data << payload
|
123
123
|
end
|
124
124
|
|
125
|
-
q.subscribe_with(consumer
|
125
|
+
q.subscribe_with(consumer)
|
126
126
|
end
|
127
127
|
t.abort_on_exception = true
|
128
128
|
sleep 1.0
|
@@ -189,17 +189,17 @@ describe Bunny::Queue, "#subscribe" do
|
|
189
189
|
ch = connection.create_channel
|
190
190
|
q = ch.queue(queue_name)
|
191
191
|
|
192
|
-
c1 = q.subscribe(exclusive: false, manual_ack: false
|
192
|
+
c1 = q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
193
193
|
end
|
194
194
|
c1.cancel
|
195
195
|
|
196
|
-
c2 = q.subscribe(exclusive: false, manual_ack: false
|
196
|
+
c2 = q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
197
197
|
delivered_keys << delivery_info.routing_key
|
198
198
|
delivered_data << payload
|
199
199
|
end
|
200
200
|
c2.cancel
|
201
201
|
|
202
|
-
q.subscribe(exclusive: false, manual_ack: false
|
202
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
203
203
|
delivered_keys << delivery_info.routing_key
|
204
204
|
delivered_data << payload
|
205
205
|
end
|
@@ -560,4 +560,30 @@ describe Bunny::Session do
|
|
560
560
|
described_class.new(logger: logger)
|
561
561
|
end
|
562
562
|
end
|
563
|
+
|
564
|
+
context "initialized with a custom connection name" do
|
565
|
+
it "uses provided connection name with default connection string" do
|
566
|
+
conn = Bunny.new(connection_name: 'test_name')
|
567
|
+
|
568
|
+
expect(conn.connection_name).to eq 'test_name'
|
569
|
+
end
|
570
|
+
|
571
|
+
it "uses provided connection name from client property hash" do
|
572
|
+
conn = Bunny.new(client_properties: {connection_name: 'cp/test_name'})
|
573
|
+
|
574
|
+
expect(conn.connection_name).to eq 'cp/test_name'
|
575
|
+
end
|
576
|
+
|
577
|
+
it "uses provided connection name with custom connection string" do
|
578
|
+
conn = Bunny.new('amqp://guest:guest@rabbitmq:5672', connection_name: 'test_name3')
|
579
|
+
|
580
|
+
expect(conn.connection_name).to eq 'test_name3'
|
581
|
+
end
|
582
|
+
|
583
|
+
it "uses provided connection name with hash options" do
|
584
|
+
conn = Bunny.new(user: 'user', password: 'p455w0rd', connection_name: 'test_name4')
|
585
|
+
|
586
|
+
expect(conn.connection_name).to eq 'test_name4'
|
587
|
+
end
|
588
|
+
end
|
563
589
|
end
|
@@ -3,248 +3,260 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
require "socket"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
puts "Will use certificates from #{CERTIFICATE_DIR}"
|
9
|
-
|
10
|
-
shared_examples_for "successful TLS connection" do
|
11
|
-
it "succeeds" do
|
12
|
-
expect(subject).to be_tls
|
13
|
-
ch = subject.create_channel
|
14
|
-
ch.confirm_select
|
15
|
-
|
16
|
-
q = ch.queue("", exclusive: true)
|
17
|
-
x = ch.default_exchange
|
18
|
-
|
19
|
-
x.publish("xyzzy", routing_key: q.name).
|
20
|
-
publish("xyzzy", routing_key: q.name).
|
21
|
-
publish("xyzzy", routing_key: q.name).
|
22
|
-
publish("xyzzy", routing_key: q.name)
|
23
|
-
|
24
|
-
x.wait_for_confirms
|
25
|
-
expect(q.message_count).to eq 4
|
26
|
-
|
27
|
-
i = 0
|
28
|
-
q.subscribe do |delivery_info, _, payload|
|
29
|
-
i += 1
|
30
|
-
end
|
31
|
-
sleep 1.0
|
32
|
-
expect(i).to eq 4
|
33
|
-
expect(q.message_count).to eq 0
|
34
|
-
|
35
|
-
ch.close
|
36
|
-
end
|
37
|
-
end
|
6
|
+
CERTIFICATE_DIR = ENV.fetch("BUNNY_CERTIFICATE_DIR", "./spec/tls")
|
7
|
+
puts "Will use certificates from #{CERTIFICATE_DIR}"
|
38
8
|
|
39
|
-
|
40
|
-
|
41
|
-
|
9
|
+
shared_examples_for "successful TLS connection" do
|
10
|
+
it "succeeds", skip: ENV["CI"] do
|
11
|
+
expect(subject).to be_tls
|
12
|
+
ch = subject.create_channel
|
13
|
+
ch.confirm_select
|
14
|
+
|
15
|
+
q = ch.queue("", exclusive: true)
|
16
|
+
x = ch.default_exchange
|
17
|
+
|
18
|
+
x.publish("xyzzy", routing_key: q.name).
|
19
|
+
publish("xyzzy", routing_key: q.name).
|
20
|
+
publish("xyzzy", routing_key: q.name).
|
21
|
+
publish("xyzzy", routing_key: q.name)
|
42
22
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
vhost: "bunny_testbed",
|
50
|
-
tls: true,
|
51
|
-
verify_peer: verify_peer,
|
52
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
53
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
54
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
23
|
+
x.wait_for_confirms
|
24
|
+
expect(q.message_count).to eq 4
|
25
|
+
|
26
|
+
i = 0
|
27
|
+
q.subscribe do |delivery_info, _, payload|
|
28
|
+
i += 1
|
55
29
|
end
|
30
|
+
sleep 1.0
|
31
|
+
expect(i).to eq 4
|
32
|
+
expect(q.message_count).to eq 0
|
56
33
|
|
57
|
-
|
58
|
-
|
34
|
+
ch.close
|
35
|
+
end
|
36
|
+
end
|
59
37
|
|
60
|
-
|
61
|
-
|
62
|
-
|
38
|
+
def local_hostname
|
39
|
+
ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "localhost")
|
40
|
+
end
|
63
41
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
expect(subject.transport.socket.hostname).to_not be_empty
|
68
|
-
end
|
42
|
+
def no_tls12_supported?
|
43
|
+
not tls12_supported?
|
44
|
+
end
|
69
45
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
46
|
+
def tls12_supported?
|
47
|
+
begin
|
48
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
49
|
+
ctx.min_version = ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
|
50
|
+
true
|
51
|
+
rescue
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
74
55
|
|
75
|
-
|
76
|
-
|
56
|
+
context "initialized with tls: true", skip: ENV["CI"] do
|
57
|
+
let(:subject) do
|
58
|
+
Bunny.new(
|
59
|
+
hostname: local_hostname(),
|
60
|
+
user: "bunny_gem",
|
61
|
+
password: "bunny_password",
|
62
|
+
vhost: "bunny_testbed",
|
63
|
+
tls: true,
|
64
|
+
verify_peer: verify_peer,
|
65
|
+
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
66
|
+
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
67
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
68
|
+
end
|
69
|
+
|
70
|
+
context "peer verification is off" do
|
71
|
+
let(:verify_peer) { false }
|
77
72
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
73
|
+
it "uses TLS port" do
|
74
|
+
expect(subject.port).to eq AMQ::Protocol::TLS_PORT
|
81
75
|
end
|
82
|
-
end
|
83
76
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
username: "bunny_gem",
|
89
|
-
password: "bunny_password",
|
90
|
-
vhost: "bunny_testbed",
|
91
|
-
tls: true,
|
92
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
93
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
94
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
95
|
-
verify_peer: false)
|
96
|
-
c.start
|
97
|
-
c
|
77
|
+
it "sends the SNI details" do
|
78
|
+
# https://github.com/ruby-amqp/bunny/issues/440
|
79
|
+
subject.start
|
80
|
+
expect(subject.transport.socket.hostname).to_not be_empty
|
98
81
|
end
|
99
82
|
|
100
83
|
after :each do
|
101
84
|
subject.close
|
102
85
|
end
|
103
|
-
|
104
|
-
include_examples "successful TLS connection"
|
105
86
|
end
|
106
87
|
|
88
|
+
context "peer verification is on" do
|
89
|
+
let(:verify_peer) { true }
|
107
90
|
|
108
|
-
|
109
|
-
|
110
|
-
c = Bunny.new(
|
111
|
-
hostname: local_hostname(),
|
112
|
-
username: "bunny_gem",
|
113
|
-
password: "bunny_password",
|
114
|
-
vhost: "bunny_testbed",
|
115
|
-
tls: true,
|
116
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
117
|
-
verify_peer: false)
|
118
|
-
c.start
|
119
|
-
c
|
91
|
+
it "uses TLS port" do
|
92
|
+
expect(subject.port).to eq AMQ::Protocol::TLS_PORT
|
120
93
|
end
|
94
|
+
end
|
95
|
+
end
|
121
96
|
|
122
|
-
|
123
|
-
|
124
|
-
|
97
|
+
describe "TLS connection to RabbitMQ with client certificates", skip: ENV["CI"] do
|
98
|
+
let(:subject) do
|
99
|
+
c = Bunny.new(
|
100
|
+
hostname: local_hostname(),
|
101
|
+
username: "bunny_gem",
|
102
|
+
password: "bunny_password",
|
103
|
+
vhost: "bunny_testbed",
|
104
|
+
tls: true,
|
105
|
+
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
106
|
+
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
107
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
108
|
+
verify_peer: false)
|
109
|
+
c.start
|
110
|
+
c
|
111
|
+
end
|
125
112
|
|
126
|
-
|
113
|
+
after :each do
|
114
|
+
subject.close
|
127
115
|
end
|
128
116
|
|
117
|
+
include_examples "successful TLS connection"
|
118
|
+
end
|
129
119
|
|
130
|
-
describe "TLS connection to RabbitMQ with a connection string" do
|
131
|
-
let(:subject) do
|
132
|
-
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
133
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
134
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
135
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
136
|
-
verify_peer: false)
|
137
|
-
c.start
|
138
|
-
c
|
139
|
-
end
|
140
120
|
|
141
|
-
|
142
|
-
|
143
|
-
|
121
|
+
describe "TLS connection to RabbitMQ without client certificates", skip: ENV["CI"] do
|
122
|
+
let(:subject) do
|
123
|
+
c = Bunny.new(
|
124
|
+
hostname: local_hostname(),
|
125
|
+
username: "bunny_gem",
|
126
|
+
password: "bunny_password",
|
127
|
+
vhost: "bunny_testbed",
|
128
|
+
tls: true,
|
129
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
130
|
+
verify_peer: false)
|
131
|
+
c.start
|
132
|
+
c
|
133
|
+
end
|
144
134
|
|
145
|
-
|
135
|
+
after :each do
|
136
|
+
subject.close
|
137
|
+
end
|
146
138
|
|
147
|
-
|
148
|
-
|
149
|
-
Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed?heartbeat=10&connection_timeout=100&channel_max=1000&verify=false&cacertfile=#{CERTIFICATE_DIR}/ca_certificate.pem&certfile=#{CERTIFICATE_DIR}/client_certificate.pem&keyfile=#{CERTIFICATE_DIR}/client_key.pem")
|
150
|
-
end
|
139
|
+
include_examples "successful TLS connection"
|
140
|
+
end
|
151
141
|
|
152
|
-
it "parses extra connection parameters" do
|
153
|
-
session.start
|
154
142
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
143
|
+
describe "TLS connection to RabbitMQ with a connection string", skip: ENV["CI"] do
|
144
|
+
let(:subject) do
|
145
|
+
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
146
|
+
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
147
|
+
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
148
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
149
|
+
verify_peer: false)
|
150
|
+
c.start
|
151
|
+
c
|
162
152
|
end
|
163
153
|
|
154
|
+
after :each do
|
155
|
+
subject.close
|
156
|
+
end
|
164
157
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
c.start
|
171
|
-
c
|
158
|
+
include_examples "successful TLS connection"
|
159
|
+
|
160
|
+
context "when URI contains query parameters" do
|
161
|
+
subject(:session) do
|
162
|
+
Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed?heartbeat=10&connection_timeout=100&channel_max=1000&verify=false&cacertfile=#{CERTIFICATE_DIR}/ca_certificate.pem&certfile=#{CERTIFICATE_DIR}/client_certificate.pem&keyfile=#{CERTIFICATE_DIR}/client_key.pem")
|
172
163
|
end
|
173
164
|
|
174
|
-
|
175
|
-
|
165
|
+
it "parses extra connection parameters" do
|
166
|
+
session.start
|
167
|
+
|
168
|
+
expect(session.uses_tls?).to eq(true)
|
169
|
+
expect(session.transport.verify_peer).to eq(false)
|
170
|
+
expect(session.transport.tls_ca_certificates).to eq(["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
171
|
+
expect(session.transport.tls_certificate_path).to eq("#{CERTIFICATE_DIR}/client_certificate.pem")
|
172
|
+
expect(session.transport.tls_key_path).to eq("#{CERTIFICATE_DIR}/client_key.pem")
|
176
173
|
end
|
174
|
+
end
|
175
|
+
end
|
177
176
|
|
178
|
-
context "peer verification is off" do
|
179
|
-
let(:verify_peer) { false }
|
180
177
|
|
181
|
-
|
178
|
+
describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key", skip: ENV["CI"] do
|
179
|
+
let(:subject) do
|
180
|
+
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
181
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
182
|
+
verify_peer: verify_peer)
|
183
|
+
c.start
|
184
|
+
c
|
185
|
+
end
|
182
186
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
end
|
187
|
-
end
|
187
|
+
after :each do
|
188
|
+
subject.close
|
189
|
+
end
|
188
190
|
|
189
|
-
|
190
|
-
|
191
|
+
context "peer verification is off" do
|
192
|
+
let(:verify_peer) { false }
|
191
193
|
|
192
|
-
|
194
|
+
include_examples "successful TLS connection"
|
193
195
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
end
|
196
|
+
it "sends the SNI details" do
|
197
|
+
# https://github.com/ruby-amqp/bunny/issues/440
|
198
|
+
expect(subject.transport.socket.hostname).to_not be_empty
|
198
199
|
end
|
199
200
|
end
|
200
201
|
|
202
|
+
context "peer verification is on" do
|
203
|
+
let(:verify_peer) { true }
|
201
204
|
|
202
|
-
|
203
|
-
let(:subject) do
|
204
|
-
c = Bunny.new(
|
205
|
-
hostname: local_hostname(),
|
206
|
-
username: "bunny_gem",
|
207
|
-
password: "bunny_password",
|
208
|
-
vhost: "bunny_testbed",
|
209
|
-
tls: true,
|
210
|
-
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
211
|
-
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
212
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
213
|
-
verify_peer: false)
|
214
|
-
c.start
|
215
|
-
c
|
216
|
-
end
|
205
|
+
include_examples "successful TLS connection"
|
217
206
|
|
218
|
-
|
219
|
-
|
207
|
+
it "sends the SNI details" do
|
208
|
+
# https://github.com/ruby-amqp/bunny/issues/440
|
209
|
+
expect(subject.transport.socket.hostname).to_not be_empty
|
220
210
|
end
|
211
|
+
end
|
212
|
+
end
|
221
213
|
|
222
|
-
|
214
|
+
|
215
|
+
describe "TLS connection to RabbitMQ with client certificates provided inline", skip: ENV["CI"] do
|
216
|
+
let(:subject) do
|
217
|
+
c = Bunny.new(
|
218
|
+
hostname: local_hostname(),
|
219
|
+
username: "bunny_gem",
|
220
|
+
password: "bunny_password",
|
221
|
+
vhost: "bunny_testbed",
|
222
|
+
tls: true,
|
223
|
+
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
224
|
+
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
225
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
226
|
+
verify_peer: false)
|
227
|
+
c.start
|
228
|
+
c
|
223
229
|
end
|
224
230
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
hostname: local_hostname(),
|
229
|
-
username: "bunny_gem",
|
230
|
-
password: "bunny_password",
|
231
|
-
vhost: "bunny_testbed",
|
232
|
-
tls: true,
|
233
|
-
tls_protocol: :TLSv1_1,
|
234
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
235
|
-
verify_peer: false)
|
236
|
-
c.start
|
237
|
-
c
|
238
|
-
end
|
231
|
+
after :each do
|
232
|
+
subject.close
|
233
|
+
end
|
239
234
|
|
240
|
-
|
241
|
-
|
242
|
-
end
|
235
|
+
include_examples "successful TLS connection"
|
236
|
+
end
|
243
237
|
|
244
|
-
|
238
|
+
describe "TLS connection to RabbitMQ with tls_version TLSv1.2 specified", skip: ENV["CI"] do
|
239
|
+
let(:subject) do
|
240
|
+
c = Bunny.new(
|
241
|
+
hostname: local_hostname(),
|
242
|
+
username: "bunny_gem",
|
243
|
+
password: "bunny_password",
|
244
|
+
vhost: "bunny_testbed",
|
245
|
+
tls: true,
|
246
|
+
tls_protocol: :TLSv1_2,
|
247
|
+
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
248
|
+
verify_peer: false)
|
249
|
+
c.start
|
250
|
+
c
|
251
|
+
end
|
245
252
|
|
246
|
-
|
247
|
-
|
248
|
-
|
253
|
+
after :each do
|
254
|
+
subject.close
|
255
|
+
end
|
256
|
+
|
257
|
+
include_examples "successful TLS connection"
|
258
|
+
|
259
|
+
it "connects using TLSv1.2", skip: no_tls12_supported? do
|
260
|
+
expect(subject.transport.socket.ssl_version).to eq "TLSv1.2"
|
249
261
|
end
|
250
262
|
end
|
@@ -4,7 +4,7 @@ describe Bunny::Session do
|
|
4
4
|
context "with unreachable host" do
|
5
5
|
it "raises Bunny::TCPConnectionFailed" do
|
6
6
|
begin
|
7
|
-
conn = Bunny.new(:hostname => "
|
7
|
+
conn = Bunny.new(:hostname => "127.0.0.254", :port => 1433)
|
8
8
|
conn.start
|
9
9
|
|
10
10
|
fail "expected 192.192.192.192 to be unreachable"
|
data/spec/issues/issue78_spec.rb
CHANGED
@@ -24,7 +24,7 @@ unless ENV["CI"]
|
|
24
24
|
ch2 = @connection1.create_channel
|
25
25
|
|
26
26
|
q = ch1.queue("", exclusive: true)
|
27
|
-
q.subscribe(manual_ack: false
|
27
|
+
q.subscribe(manual_ack: false) do |delivery_info, properties, payload|
|
28
28
|
delivered_data << payload
|
29
29
|
end
|
30
30
|
sleep 0.5
|
@@ -57,7 +57,7 @@ unless ENV["CI"]
|
|
57
57
|
sleep 0.7
|
58
58
|
expect(q.message_count).to eq 3
|
59
59
|
|
60
|
-
q.subscribe(manual_ack: false
|
60
|
+
q.subscribe(manual_ack: false) do |delivery_info, properties, payload|
|
61
61
|
delivered_data << payload
|
62
62
|
end
|
63
63
|
sleep 0.7
|
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: 2.
|
4
|
+
version: 2.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Duncan
|
@@ -12,31 +12,32 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: amq-protocol
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.0
|
24
21
|
- - "~>"
|
25
22
|
- !ruby/object:Gem::Version
|
26
23
|
version: '2.3'
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.3.1
|
27
27
|
type: :runtime
|
28
28
|
prerelease: false
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.3.0
|
34
31
|
- - "~>"
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '2.3'
|
37
|
-
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.3.1
|
37
|
+
description: Easy to use, feature complete Ruby client for RabbitMQ 3.3 and later
|
38
|
+
versions.
|
38
39
|
email:
|
39
|
-
-
|
40
|
+
- michael.s.klishin@gmail.com
|
40
41
|
executables: []
|
41
42
|
extensions: []
|
42
43
|
extra_rdoc_files:
|
@@ -240,10 +241,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
241
|
- !ruby/object:Gem::Version
|
241
242
|
version: '0'
|
242
243
|
requirements: []
|
243
|
-
rubygems_version: 3.
|
244
|
+
rubygems_version: 3.1.2
|
244
245
|
signing_key:
|
245
246
|
specification_version: 4
|
246
|
-
summary:
|
247
|
+
summary: Popular easy to use Ruby client for RabbitMQ
|
247
248
|
test_files:
|
248
249
|
- spec/config/enabled_plugins
|
249
250
|
- spec/config/rabbitmq.conf
|