amqp 1.3.0 → 1.4.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.
- checksums.yaml +4 -4
- data/ChangeLog.md +8 -0
- data/README.md +33 -41
- data/lib/amqp/consumer.rb +9 -8
- data/lib/amqp/session.rb +32 -6
- data/lib/amqp/settings.rb +9 -1
- data/lib/amqp/version.rb +1 -1
- data/spec/integration/exchange_to_exchange_binding_spec.rb +8 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a27af25790fbbfceee41b2ed96246b3e3736624a
|
4
|
+
data.tar.gz: 2dbac00d7f5e582cb91c6b6fa4ee4510fcceb8df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f218bcdf94cd7e0a02a82717860c63d8476a7a48ab08c965a9639197d6cdb815a3fb18ca4c7ac4de73bd8ef78aae594b8cca4fd6c3c25ce59499ef2ee9acddf
|
7
|
+
data.tar.gz: 21df041f087ba88c6fd67f64c9a12869c411f48cdd270d9e16fe6578df5d80f7631094de05e7cc920bc9c9fdf7c5be07f6a0be55bdfe424b2aa432e3a04bc98b
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## Changes Between 1.3.x and 1.4.0
|
2
|
+
|
3
|
+
### connection.blocked Support
|
4
|
+
|
5
|
+
[connection.blocked](https://www.rabbitmq.com/connection-blocked.html) notifications
|
6
|
+
are now correctly supported by the library.
|
7
|
+
|
8
|
+
|
1
9
|
## Changes Between 1.2.x and 1.3.0
|
2
10
|
|
3
11
|
### Exchange-to-Exchange Bindings Support
|
data/README.md
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
# Ruby amqp gem: the asynchronous Ruby RabbitMQ client
|
2
2
|
|
3
|
-
[Ruby amqp gem](http://rubyamqp.info) is a
|
4
|
-
|
3
|
+
[Ruby amqp gem](http://rubyamqp.info) is a feature-rich,
|
4
|
+
EventMachine-based RabbitMQ client with batteries included.
|
5
|
+
|
6
|
+
It implement [AMQP
|
7
|
+
0.9.1](http://www.rabbitmq.com/tutorials/amqp-concepts.html) and
|
8
|
+
support [RabbitMQ extensions to AMQP
|
9
|
+
0.9.1](http://www.rabbitmq.com/extensions.html).
|
5
10
|
|
6
|
-
* Ruby 2.1
|
7
|
-
* Ruby 2.0
|
8
|
-
* Ruby 1.9.3
|
9
|
-
* [JRuby](http://jruby.org)
|
10
|
-
* [Rubinius](http://rubini.us)
|
11
|
-
* Ruby 1.9.2
|
12
|
-
* Ruby 1.8.7
|
13
|
-
* [REE](http://www.rubyenterpriseedition.com),
|
14
11
|
|
15
|
-
|
12
|
+
## A Word of Warning: Use This Only If You Already Use EventMachine
|
16
13
|
|
17
|
-
|
14
|
+
Unless you **already use EventMachine**, there is no real reason to
|
15
|
+
use this client. Consider [Bunny](http://rubybunny.info) or [March Hare](http://rubymarchhare.info) instead.
|
16
|
+
|
17
|
+
amqp gem brings in a fair share of EventMachine complexity which
|
18
|
+
cannot be fully eliminated. Event loop blocking, writes that happen
|
19
|
+
at the end of loop tick, uncaught exceptions in event loop silently killing it:
|
20
|
+
it's not worth the pain unless you've already deeply invested in EventMachine
|
21
|
+
and understand how it works.
|
22
|
+
|
23
|
+
So, just use Bunny or March Hare. You will be much happier.
|
18
24
|
|
19
25
|
|
20
26
|
## I know what RabbitMQ is, how do I get started?
|
@@ -126,6 +132,20 @@ and is written in a form of a tutorial. See [AMQP 0.9.1 Model Explained](http://
|
|
126
132
|
to learn more about RabbitMQ protocol principles & concepts.
|
127
133
|
|
128
134
|
|
135
|
+
## Supported Ruby Versions
|
136
|
+
|
137
|
+
This library works with
|
138
|
+
|
139
|
+
* Ruby 2.1
|
140
|
+
* Ruby 2.0
|
141
|
+
* Ruby 1.9.3
|
142
|
+
* [JRuby](http://jruby.org)
|
143
|
+
* [Rubinius](http://rubini.us)
|
144
|
+
* Ruby 1.9.2
|
145
|
+
* Ruby 1.8.7
|
146
|
+
* [REE](http://www.rubyenterpriseedition.com),
|
147
|
+
|
148
|
+
|
129
149
|
|
130
150
|
## Documentation: tutorials, guides & API reference
|
131
151
|
|
@@ -211,7 +231,7 @@ amqp gem is maintained by [Michael Klishin](http://twitter.com/michaelklishin).
|
|
211
231
|
|
212
232
|
## License ##
|
213
233
|
|
214
|
-
|
234
|
+
amqp gem is licensed under the [Ruby License](http://www.ruby-lang.org/en/LICENSE.txt).
|
215
235
|
|
216
236
|
|
217
237
|
|
@@ -247,34 +267,6 @@ Special thanks to Dmitriy Samovskiy, Ben Hood and Tony Garnock-Jones.
|
|
247
267
|
|
248
268
|
|
249
269
|
|
250
|
-
## (Very) Short FAQ ##
|
251
|
-
|
252
|
-
### So, does amqp gem only work with RabbitMQ?
|
253
|
-
|
254
|
-
This library is developed and tested primarily with [RabbitMQ](http://rabbitmq.com), although it should be compatible with any
|
255
|
-
server implementing the [AMQP 0.9.1 spec](http://bit.ly/hw2ELX). For AMQP 0.8 brokers, use amqp gem version 0.7.x.
|
256
|
-
|
257
|
-
### Why isn't Ruby 1.8.7-p249 supported? Will it be supported in the future?
|
258
|
-
|
259
|
-
In order to make code like the following (pseudo-synchronous) work
|
260
|
-
|
261
|
-
``` ruby
|
262
|
-
conn = AMQP.connect
|
263
|
-
ch = AMQP::Channel.new(conn)
|
264
|
-
|
265
|
-
ex = ch.default_exchange
|
266
|
-
ex.publish(some_data)
|
267
|
-
```
|
268
|
-
|
269
|
-
and not be affected by this [Ruby 1.8.7-p249-specific bug (super called outside of method)](http://bit.ly/iONBmH), we need to
|
270
|
-
avoid any inheritance for key amqp gem classes: Channel, Queue, Exchange, Consumer. This will take a significant refactoring effort and
|
271
|
-
we do not expect this to change at this time.
|
272
|
-
|
273
|
-
|
274
|
-
### How does amqp gem relate to amq-client gem, amq-protocol and libraries like Bunny?
|
275
|
-
|
276
|
-
See [this page about AMQP gems family](https://github.com/ruby-amqp/amq-client/blob/master/README.textile)
|
277
|
-
|
278
270
|
|
279
271
|
[](https://bitdeli.com/free "Bitdeli Badge")
|
280
272
|
|
data/lib/amqp/consumer.rb
CHANGED
@@ -113,13 +113,6 @@ module AMQP
|
|
113
113
|
@channel.once_open do
|
114
114
|
@queue.once_declared do
|
115
115
|
@connection.send_frame(AMQ::Protocol::Basic::Cancel.encode(@channel.id, @consumer_tag, nowait))
|
116
|
-
self.clear_callbacks(:delivery)
|
117
|
-
self.clear_callbacks(:consume)
|
118
|
-
self.clear_callbacks(:scancel)
|
119
|
-
|
120
|
-
self.unregister_with_channel
|
121
|
-
self.unregister_with_queue
|
122
|
-
|
123
116
|
if !nowait
|
124
117
|
self.redefine_callback(:cancel, &block)
|
125
118
|
@channel.consumers_awaiting_cancel_ok.push(self)
|
@@ -304,6 +297,11 @@ module AMQP
|
|
304
297
|
end # handle_consume_ok(consume_ok)
|
305
298
|
|
306
299
|
def handle_cancel_ok(cancel_ok)
|
300
|
+
self.exec_callback_once(:cancel, cancel_ok)
|
301
|
+
|
302
|
+
self.unregister_with_channel
|
303
|
+
self.unregister_with_queue
|
304
|
+
|
307
305
|
@consumer_tag = nil
|
308
306
|
|
309
307
|
# detach from object graph so that this object will be garbage-collected
|
@@ -311,7 +309,10 @@ module AMQP
|
|
311
309
|
@channel = nil
|
312
310
|
@connection = nil
|
313
311
|
|
314
|
-
self.
|
312
|
+
self.clear_callbacks(:delivery)
|
313
|
+
self.clear_callbacks(:consume)
|
314
|
+
self.clear_callbacks(:cancel)
|
315
|
+
self.clear_callbacks(:scancel)
|
315
316
|
end # handle_cancel_ok(method)
|
316
317
|
|
317
318
|
|
data/lib/amqp/session.rb
CHANGED
@@ -396,6 +396,18 @@ module AMQP
|
|
396
396
|
# @endgroup
|
397
397
|
|
398
398
|
|
399
|
+
# @group Blocked connection notifications
|
400
|
+
|
401
|
+
def on_blocked(&fn)
|
402
|
+
@on_blocked = fn
|
403
|
+
end
|
404
|
+
|
405
|
+
def on_unblocked(&fn)
|
406
|
+
@on_unblocked = fn
|
407
|
+
end
|
408
|
+
|
409
|
+
# @endgroup
|
410
|
+
|
399
411
|
|
400
412
|
#
|
401
413
|
# Implementation
|
@@ -600,7 +612,7 @@ module AMQP
|
|
600
612
|
# now we can set it. MK.
|
601
613
|
@had_successfully_connected_before = true
|
602
614
|
@reconnecting = false
|
603
|
-
@
|
615
|
+
@handling_skipped_heartbeats = false
|
604
616
|
@last_server_heartbeat = Time.now
|
605
617
|
|
606
618
|
self.handshake
|
@@ -687,9 +699,9 @@ module AMQP
|
|
687
699
|
# heartbeat interval set via :heartbeat_interval option on connection.
|
688
700
|
#
|
689
701
|
# @api plugin
|
690
|
-
def
|
691
|
-
if !@
|
692
|
-
@
|
702
|
+
def handle_skipped_heartbeats
|
703
|
+
if !@handling_skipped_heartbeats && @tcp_connection_established && !@intentionally_closing_connection
|
704
|
+
@handling_skipped_heartbeats = true
|
693
705
|
self.cancel_heartbeat_sender
|
694
706
|
|
695
707
|
self.run_skipped_heartbeats_callbacks
|
@@ -963,10 +975,10 @@ module AMQP
|
|
963
975
|
# Sends a heartbeat frame if connection is open.
|
964
976
|
# @api plugin
|
965
977
|
def send_heartbeat
|
966
|
-
if tcp_connection_established? && !@
|
978
|
+
if tcp_connection_established? && !@handling_skipped_heartbeats && @last_server_heartbeat
|
967
979
|
if @last_server_heartbeat < (Time.now - (self.heartbeat_interval * 2)) && !reconnecting?
|
968
980
|
logger.error "[amqp] Detected missing server heartbeats"
|
969
|
-
self.
|
981
|
+
self.handle_skipped_heartbeats
|
970
982
|
end
|
971
983
|
send_frame(AMQ::Protocol::HeartbeatFrame)
|
972
984
|
end
|
@@ -1055,6 +1067,13 @@ module AMQP
|
|
1055
1067
|
end # handle_close_ok(close_ok)
|
1056
1068
|
|
1057
1069
|
|
1070
|
+
def handle_connection_blocked(connection_blocked)
|
1071
|
+
@on_blocked.call(self, connection_blocked) if @on_blocked
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
def handle_connection_unblocked(connection_unblocked)
|
1075
|
+
@on_unblocked.call(self, connection_unblocked) if @on_unblocked
|
1076
|
+
end
|
1058
1077
|
|
1059
1078
|
protected
|
1060
1079
|
|
@@ -1125,6 +1144,13 @@ module AMQP
|
|
1125
1144
|
connection.handle_close_ok(frame.decode_payload)
|
1126
1145
|
end
|
1127
1146
|
|
1147
|
+
self.handle(AMQ::Protocol::Connection::Blocked) do |connection, frame|
|
1148
|
+
connection.handle_connection_blocked(frame.decode_payload)
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
self.handle(AMQ::Protocol::Connection::Unblocked) do |connection, frame|
|
1152
|
+
connection.handle_connection_unblocked(frame.decode_payload)
|
1153
|
+
end
|
1128
1154
|
|
1129
1155
|
|
1130
1156
|
|
data/lib/amqp/settings.rb
CHANGED
@@ -45,7 +45,15 @@ module AMQP
|
|
45
45
|
:platform => ::RUBY_DESCRIPTION,
|
46
46
|
:product => "amqp gem",
|
47
47
|
:information => "http://github.com/ruby-amqp/amqp",
|
48
|
-
:version => AMQP::VERSION
|
48
|
+
:version => AMQP::VERSION,
|
49
|
+
:capabilities => {
|
50
|
+
:publisher_confirms => true,
|
51
|
+
:consumer_cancel_notify => true,
|
52
|
+
:exchange_exchange_bindings => true,
|
53
|
+
:"basic.nack" => true,
|
54
|
+
:"connection.blocked" => true,
|
55
|
+
:authentication_failure_close => true
|
56
|
+
}
|
49
57
|
}
|
50
58
|
|
51
59
|
def self.client_properties
|
data/lib/amqp/version.rb
CHANGED
@@ -54,7 +54,7 @@ describe AMQP::Channel do
|
|
54
54
|
source.publish("x")
|
55
55
|
end
|
56
56
|
end
|
57
|
-
done(0.
|
57
|
+
done(0.5) { messages.should == ["x"] }
|
58
58
|
end
|
59
59
|
|
60
60
|
it "can be unbound" do
|
@@ -82,7 +82,7 @@ describe AMQP::Channel do
|
|
82
82
|
destination.bind(source, :nowait => true) do
|
83
83
|
callback_called = true
|
84
84
|
end
|
85
|
-
done(0.
|
85
|
+
done(0.5) { callback_called.should be_false}
|
86
86
|
end
|
87
87
|
|
88
88
|
end #context
|
@@ -92,16 +92,15 @@ describe AMQP::Channel do
|
|
92
92
|
source = @channel.topic("topic-exchange-source")
|
93
93
|
destination = @channel.topic("topic-exchange-destination")
|
94
94
|
messages = []
|
95
|
-
destination.bind(source) do
|
95
|
+
destination.bind(source, :routing_key => "#") do
|
96
96
|
queue = @channel.queue("ex-to-ex-default-key", :auto_delete => true)
|
97
|
-
queue.subscribe do |metadata, payload|
|
97
|
+
queue.bind(destination, :routing_key => "#").subscribe do |metadata, payload|
|
98
98
|
messages << payload
|
99
99
|
end
|
100
|
-
|
101
|
-
|
102
|
-
end
|
100
|
+
|
101
|
+
source.publish("a", :routing_key => "lalalala")
|
103
102
|
end
|
104
|
-
done(0.
|
103
|
+
done(0.5) { messages.should == ["a"] }
|
105
104
|
end
|
106
105
|
|
107
106
|
it "using routing key 'foo'" do
|
@@ -117,7 +116,7 @@ describe AMQP::Channel do
|
|
117
116
|
source.publish("b", :routing_key => "foo")
|
118
117
|
end
|
119
118
|
end
|
120
|
-
done(0.
|
119
|
+
done(0.5) { messages.should == ["b"]}
|
121
120
|
end
|
122
121
|
end #context
|
123
122
|
end # describe
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Gupta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: eventmachine
|
@@ -324,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
324
|
version: '0'
|
325
325
|
requirements: []
|
326
326
|
rubyforge_project: amqp
|
327
|
-
rubygems_version: 2.
|
327
|
+
rubygems_version: 2.2.2
|
328
328
|
signing_key:
|
329
329
|
specification_version: 4
|
330
330
|
summary: Widely used, feature-rich asynchronous RabbitMQ client with batteries included
|