bunny 1.4.1 → 1.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/ChangeLog.md +19 -5
- data/README.md +23 -3
- data/examples/guides/extensions/basic_nack.rb +1 -1
- data/examples/guides/extensions/dead_letter_exchange.rb +1 -1
- data/examples/guides/queues/redeliveries.rb +2 -2
- data/lib/bunny.rb +1 -1
- data/lib/bunny/channel.rb +34 -21
- data/lib/bunny/exceptions.rb +17 -2
- data/lib/bunny/exchange.rb +14 -22
- data/lib/bunny/queue.rb +19 -12
- data/lib/bunny/session.rb +67 -57
- data/lib/bunny/version.rb +1 -1
- data/spec/config/enabled_plugins +1 -0
- data/spec/config/rabbitmq.config +18 -0
- data/spec/higher_level_api/integration/basic_ack_spec.rb +29 -2
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_nack_spec.rb +5 -5
- data/spec/higher_level_api/integration/basic_reject_spec.rb +3 -3
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +79 -2
- data/spec/higher_level_api/integration/connection_spec.rb +24 -0
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +1 -1
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +1 -1
- data/spec/issues/issue78_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -7
- data/spec/tls/ca_certificate.pem +18 -0
- data/spec/tls/ca_key.pem +27 -0
- data/spec/tls/client_cert.pem +16 -16
- data/spec/tls/client_key.pem +25 -25
- data/spec/tls/server_cert.pem +16 -16
- data/spec/tls/server_key.pem +25 -25
- metadata +12 -10
- data/.ruby-version +0 -1
- data/lib/bunny/compatibility.rb +0 -24
- data/spec/compatibility/queue_declare_spec.rb +0 -44
- data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2e3f4cbc8cb08e8cebce0b4ae4b87056744fcf4
|
4
|
+
data.tar.gz: 17d65911fb9a606ea5d5f7b9af0f21dd811266bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d16bfeab544fb842e3030bf1aa6fd7e7ed4a97966577934f45b8d5988e2fbd4d33125a1c601c8a44d6ef150b3707df52da07d5ff6519c64a461bdaad1869d6ed
|
7
|
+
data.tar.gz: 53766bae9993a4e3b5d064101d28023c435ea19ad051f2b05050674b1609fc4e7efbf644852630b2a7b58ddab362cde94d8360ce1d637d528ea83ed7350eb63d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,11 +1,25 @@
|
|
1
|
-
## Changes between Bunny 1.4.0 and 1.
|
1
|
+
## Changes between Bunny 1.4.0 and 1.5.0
|
2
2
|
|
3
|
-
###
|
3
|
+
### Convenience Method for Temporary (Server-named, Exclusive) Queue Declaration
|
4
4
|
|
5
|
-
Bunny
|
6
|
-
|
5
|
+
`Bunny::Channel#temporary_queue` is a convenience method that declares a new
|
6
|
+
server-named exclusive queue:
|
7
7
|
|
8
|
-
|
8
|
+
``` ruby
|
9
|
+
q = ch.temporary_queue
|
10
|
+
```
|
11
|
+
|
12
|
+
Contributed by Daniel Schierbeck (Zendesk).
|
13
|
+
|
14
|
+
|
15
|
+
### Host Lists
|
16
|
+
|
17
|
+
It is now possible to pass the `:hosts` option to `Bunny.new`/`Bunny::Session#initialize`.
|
18
|
+
When connection to RabbitMQ (including during connection recovery), a random host
|
19
|
+
will be chosen from the list.
|
20
|
+
|
21
|
+
Connection shuffling and robustness improvements are contributed by
|
22
|
+
Andre Foeken (Nedap).
|
9
23
|
|
10
24
|
|
11
25
|
## Changes between Bunny 1.3.0 and 1.4.0
|
data/README.md
CHANGED
@@ -64,11 +64,11 @@ Bunny `0.7.x` and earlier versions support RabbitMQ 1.x and 2.x.
|
|
64
64
|
|
65
65
|
## Project Maturity
|
66
66
|
|
67
|
-
Bunny is a mature library (started in early 2009)
|
67
|
+
Bunny is a mature library (started in early 2009) with
|
68
68
|
a stable public API.
|
69
69
|
|
70
70
|
Before version 0.9, **a lot** of functionality was missing. Version
|
71
|
-
0.9 can be considered to be "second birthday" for Bunny as it was
|
71
|
+
0.9 can be considered to be a "second birthday" for Bunny as it was
|
72
72
|
rewritten from scratch with over a dozen of preview releases over the
|
73
73
|
course of about a year.
|
74
74
|
|
@@ -95,7 +95,7 @@ gem install bunny
|
|
95
95
|
To use Bunny in a project managed with Bundler:
|
96
96
|
|
97
97
|
``` ruby
|
98
|
-
gem "bunny", "~> 1.
|
98
|
+
gem "bunny", "~> 1.4.0"
|
99
99
|
```
|
100
100
|
|
101
101
|
|
@@ -191,6 +191,26 @@ try to explain what behavior you expected and why. Bonus points for
|
|
191
191
|
contributing failing test cases.
|
192
192
|
|
193
193
|
|
194
|
+
### Running the specs
|
195
|
+
|
196
|
+
The cleanest way to get the specs running is by starting a clean rabbitmq server
|
197
|
+
node on your machine specifically for the bunny specs.
|
198
|
+
|
199
|
+
Make sure you have a recent version of RabbitMQ (> 3.2) and run the following command
|
200
|
+
from the base directory of the gem:
|
201
|
+
|
202
|
+
`RABBITMQ_NODENAME=bunny RABBITMQ_CONFIG_FILE=./spec/config/rabbitmq RABBITMQ_ENABLED_PLUGINS_FILE=./spec/config/enabled_plugins rabbitmq-server`
|
203
|
+
|
204
|
+
> The specs use the Rabbitmq management plugin and require an SSL port to be available. The config files in the spec/config directory enable these. Please note that this config uses verify_none because the certificates are expired.
|
205
|
+
|
206
|
+
Next up you'll need to prepare your node for the specs (Only once):
|
207
|
+
|
208
|
+
`RABBITMQ_NODENAME=bunny ./bin/ci/before_build.sh`
|
209
|
+
|
210
|
+
And then run the specs:
|
211
|
+
|
212
|
+
`RABBITMQ_NODENAME=bunny rspec`
|
213
|
+
|
194
214
|
## Other Ruby RabbitMQ Clients
|
195
215
|
|
196
216
|
Other widely used Ruby RabbitMQ clients are [March
|
@@ -20,7 +20,7 @@ dlq = ch.queue("", :exclusive => true).bind(dlx)
|
|
20
20
|
x.publish("")
|
21
21
|
sleep 0.2
|
22
22
|
|
23
|
-
delivery_info, _, _ = q.pop(:
|
23
|
+
delivery_info, _, _ = q.pop(:manual_ack => true)
|
24
24
|
puts "#{dlq.message_count} messages dead lettered so far"
|
25
25
|
puts "Rejecting a message"
|
26
26
|
ch.nack(delivery_info.delivery_tag)
|
@@ -29,7 +29,7 @@ x = ch3.direct("amq.direct")
|
|
29
29
|
q1 = ch1.queue("bunny.examples.acknowledgements.explicit", :auto_delete => false)
|
30
30
|
q1.purge
|
31
31
|
|
32
|
-
q1.bind(x).subscribe(:
|
32
|
+
q1.bind(x).subscribe(:manual_ack => true, :block => false) do |delivery_info, properties, payload|
|
33
33
|
# do some work
|
34
34
|
sleep(0.2)
|
35
35
|
|
@@ -46,7 +46,7 @@ q1.bind(x).subscribe(:ack => true, :block => false) do |delivery_info, propertie
|
|
46
46
|
end
|
47
47
|
|
48
48
|
q2 = ch2.queue("bunny.examples.acknowledgements.explicit", :auto_delete => false)
|
49
|
-
q2.bind(x).subscribe(:
|
49
|
+
q2.bind(x).subscribe(:manual_ack => true, :block => false) do |delivery_info, properties, payload|
|
50
50
|
# do some work
|
51
51
|
sleep(0.2)
|
52
52
|
|
data/lib/bunny.rb
CHANGED
data/lib/bunny/channel.rb
CHANGED
@@ -37,11 +37,10 @@ module Bunny
|
|
37
37
|
# Channels can be opened either via `Bunny::Session#create_channel` (sufficient in the majority
|
38
38
|
# of cases) or by instantiating `Bunny::Channel` directly:
|
39
39
|
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# conn.start
|
40
|
+
# conn = Bunny.new
|
41
|
+
# conn.start
|
43
42
|
#
|
44
|
-
#
|
43
|
+
# ch = conn.create_channel
|
45
44
|
#
|
46
45
|
# This will automatically allocate a channel id.
|
47
46
|
#
|
@@ -51,10 +50,8 @@ module Bunny
|
|
51
50
|
# closed, too. Closed channels can no longer be used. Attempts to use them will raise
|
52
51
|
# {Bunny::ChannelAlreadyClosed}.
|
53
52
|
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# ch = conn.create_channel
|
57
|
-
# ch.close
|
53
|
+
# ch = conn.create_channel
|
54
|
+
# ch.close
|
58
55
|
#
|
59
56
|
# ## Higher-level API
|
60
57
|
#
|
@@ -404,6 +401,16 @@ module Bunny
|
|
404
401
|
register_queue(q)
|
405
402
|
end
|
406
403
|
|
404
|
+
# Declares a new server-named queue that is automatically deleted when the
|
405
|
+
# connection is closed.
|
406
|
+
#
|
407
|
+
# @return [Bunny::Queue] Queue that was declared
|
408
|
+
# @see #queue
|
409
|
+
# @api public
|
410
|
+
def temporary_queue(opts = {})
|
411
|
+
queue("", opts.merge(:exclusive => true))
|
412
|
+
end
|
413
|
+
|
407
414
|
# @endgroup
|
408
415
|
|
409
416
|
|
@@ -566,7 +573,8 @@ module Bunny
|
|
566
573
|
# @param [String] queue Queue name
|
567
574
|
# @param [Hash] opts Options
|
568
575
|
#
|
569
|
-
# @option opts [Boolean] :ack (true)
|
576
|
+
# @option opts [Boolean] :ack (true) [DEPRECATED] Use :manual_ack instead
|
577
|
+
# @option opts [Boolean] :manual_ack (true) Will this message be acknowledged manually?
|
570
578
|
#
|
571
579
|
# @return [Array] A triple of delivery info, message properties and message content
|
572
580
|
#
|
@@ -575,15 +583,20 @@ module Bunny
|
|
575
583
|
# conn.start
|
576
584
|
# ch = conn.create_channel
|
577
585
|
# # here we assume the queue already exists and has messages
|
578
|
-
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue1", :
|
586
|
+
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue1", :manual_ack => true)
|
579
587
|
# ch.acknowledge(delivery_info.delivery_tag)
|
580
588
|
# @see Bunny::Queue#pop
|
581
589
|
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
|
582
590
|
# @api public
|
583
|
-
def basic_get(queue, opts = {:
|
591
|
+
def basic_get(queue, opts = {:manual_ack => true})
|
584
592
|
raise_if_no_longer_open!
|
585
593
|
|
586
|
-
|
594
|
+
unless opts[:ack].nil?
|
595
|
+
warn "[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead."
|
596
|
+
opts[:manual_ack] = opts[:ack]
|
597
|
+
end
|
598
|
+
|
599
|
+
@connection.send_frame(AMQ::Protocol::Basic::Get.encode(@id, queue, !(opts[:manual_ack])))
|
587
600
|
# this is a workaround for the edge case when basic_get is called in a tight loop
|
588
601
|
# and network goes down we need to perform recovery. The problem is, basic_get will
|
589
602
|
# keep blocking the thread that calls it without clear way to constantly unblock it
|
@@ -675,7 +688,7 @@ module Bunny
|
|
675
688
|
#
|
676
689
|
# ch = conn.create_channel
|
677
690
|
# # we assume the queue exists and has messages
|
678
|
-
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :
|
691
|
+
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
679
692
|
# ch.basic_reject(delivery_info.delivery_tag, true)
|
680
693
|
#
|
681
694
|
# @see Bunny::Channel#basic_nack
|
@@ -710,7 +723,7 @@ module Bunny
|
|
710
723
|
#
|
711
724
|
# ch = conn.create_channel
|
712
725
|
# # we assume the queue exists and has messages
|
713
|
-
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :
|
726
|
+
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
714
727
|
# ch.basic_ack(delivery_info.delivery_tag)
|
715
728
|
#
|
716
729
|
# @example Ack multiple messages fetched via basic.get
|
@@ -719,9 +732,9 @@ module Bunny
|
|
719
732
|
#
|
720
733
|
# ch = conn.create_channel
|
721
734
|
# # we assume the queue exists and has messages
|
722
|
-
# _, _, payload1 = ch.basic_get("bunny.examples.queue3", :
|
723
|
-
# _, _, payload2 = ch.basic_get("bunny.examples.queue3", :
|
724
|
-
# delivery_info, properties, payload3 = ch.basic_get("bunny.examples.queue3", :
|
735
|
+
# _, _, payload1 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
736
|
+
# _, _, payload2 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
737
|
+
# delivery_info, properties, payload3 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
725
738
|
# # ack all fetched messages up to payload3
|
726
739
|
# ch.basic_ack(delivery_info.delivery_tag, true)
|
727
740
|
#
|
@@ -769,7 +782,7 @@ module Bunny
|
|
769
782
|
#
|
770
783
|
# ch = conn.create_channel
|
771
784
|
# # we assume the queue exists and has messages
|
772
|
-
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :
|
785
|
+
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
773
786
|
# ch.basic_nack(delivery_info.delivery_tag, false, true)
|
774
787
|
#
|
775
788
|
#
|
@@ -779,9 +792,9 @@ module Bunny
|
|
779
792
|
#
|
780
793
|
# ch = conn.create_channel
|
781
794
|
# # we assume the queue exists and has messages
|
782
|
-
# _, _, payload1 = ch.basic_get("bunny.examples.queue3", :
|
783
|
-
# _, _, payload2 = ch.basic_get("bunny.examples.queue3", :
|
784
|
-
# delivery_info, properties, payload3 = ch.basic_get("bunny.examples.queue3", :
|
795
|
+
# _, _, payload1 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
796
|
+
# _, _, payload2 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
797
|
+
# delivery_info, properties, payload3 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
|
785
798
|
# # requeue all fetched messages up to payload3
|
786
799
|
# ch.basic_nack(delivery_info.delivery_tag, true, true)
|
787
800
|
#
|
data/lib/bunny/exceptions.rb
CHANGED
@@ -4,6 +4,12 @@ module Bunny
|
|
4
4
|
class Exception < ::StandardError
|
5
5
|
end
|
6
6
|
|
7
|
+
class HostListDepleted < Exception
|
8
|
+
def initialize
|
9
|
+
super("No more hosts to try in the supplied list of hosts")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
# Indicates a network failure. If automatic network
|
8
14
|
# recovery mode is enabled, these will be typically handled
|
9
15
|
# by the client itself.
|
@@ -54,7 +60,6 @@ module Bunny
|
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
57
|
-
|
58
63
|
# Raised when TCP connection to RabbitMQ fails because of an unresolved
|
59
64
|
# hostname, connectivity problem, etc
|
60
65
|
class TCPConnectionFailed < Exception
|
@@ -67,7 +72,17 @@ module Bunny
|
|
67
72
|
when Exception then
|
68
73
|
e.message
|
69
74
|
end
|
70
|
-
|
75
|
+
if hostname && port
|
76
|
+
super("Could not establish TCP connection to #{hostname}:#{port}: #{m}")
|
77
|
+
else
|
78
|
+
super(m)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class TCPConnectionFailedForAllHosts < TCPConnectionFailed
|
84
|
+
def initialize
|
85
|
+
super("Could not establish TCP connection to any of the configured hosts", nil, nil)
|
71
86
|
end
|
72
87
|
end
|
73
88
|
|
data/lib/bunny/exchange.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "bunny/compatibility"
|
2
|
-
|
3
1
|
module Bunny
|
4
2
|
# Represents AMQP 0.9.1 exchanges.
|
5
3
|
#
|
@@ -7,9 +5,6 @@ module Bunny
|
|
7
5
|
# @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions guide
|
8
6
|
class Exchange
|
9
7
|
|
10
|
-
include Bunny::Compatibility
|
11
|
-
|
12
|
-
|
13
8
|
#
|
14
9
|
# API
|
15
10
|
#
|
@@ -33,12 +28,12 @@ module Bunny
|
|
33
28
|
attr_accessor :opts
|
34
29
|
|
35
30
|
|
36
|
-
# The default exchange.
|
37
|
-
#
|
38
|
-
# the following routing semantics: messages will be routed to the queue
|
39
|
-
#
|
40
|
-
# a routing key of "weather.usa.ca.sandiego" and there is a queue
|
41
|
-
#
|
31
|
+
# The default exchange. This exchange is a direct exchange that is predefined by the broker
|
32
|
+
# and that cannot be removed. Every queue is bound to this exchange by default with
|
33
|
+
# the following routing semantics: messages will be routed to the queue with the same
|
34
|
+
# name as the message's routing key. In other words, if a message is published with
|
35
|
+
# a routing key of "weather.usa.ca.sandiego" and there is a queue with this name,
|
36
|
+
# the message will be routed to the queue.
|
42
37
|
#
|
43
38
|
# @param [Bunny::Channel] channel_or_connection Channel to use. {Bunny::Session} instances
|
44
39
|
# are only supported for backwards compatibility.
|
@@ -46,11 +41,11 @@ module Bunny
|
|
46
41
|
# @example Publishing a messages to the tasks queue
|
47
42
|
# channel = Bunny::Channel.new(connection)
|
48
43
|
# tasks_queue = channel.queue("tasks")
|
49
|
-
# Bunny::Exchange.default(channel).publish("make clean", routing_key => "tasks")
|
44
|
+
# Bunny::Exchange.default(channel).publish("make clean", :routing_key => "tasks")
|
50
45
|
#
|
51
46
|
# @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
|
52
47
|
# @see http://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf AMQP 0.9.1 specification (Section 2.1.2.4)
|
53
|
-
# @note Do not confuse default exchange with amq.direct: amq.direct is a pre-defined direct
|
48
|
+
# @note Do not confuse the default exchange with amq.direct: amq.direct is a pre-defined direct
|
54
49
|
# exchange that doesn't have any special routing semantics.
|
55
50
|
# @return [Exchange] An instance that corresponds to the default exchange (of type direct).
|
56
51
|
# @api public
|
@@ -58,11 +53,10 @@ module Bunny
|
|
58
53
|
self.new(channel_or_connection, :direct, AMQ::Protocol::EMPTY_STRING, :no_declare => true)
|
59
54
|
end
|
60
55
|
|
61
|
-
# @param [Bunny::Channel]
|
62
|
-
#
|
63
|
-
# @param [
|
64
|
-
# @param [
|
65
|
-
# @param [Hash] opts Exchange properties
|
56
|
+
# @param [Bunny::Channel] channel Channel this exchange will use.
|
57
|
+
# @param [Symbol,String] type Exchange type
|
58
|
+
# @param [String] name Exchange name
|
59
|
+
# @param [Hash] opts Exchange properties
|
66
60
|
#
|
67
61
|
# @option opts [Boolean] :durable (false) Should this exchange be durable?
|
68
62
|
# @option opts [Boolean] :auto_delete (false) Should this exchange be automatically deleted when it is no longer used?
|
@@ -75,10 +69,8 @@ module Bunny
|
|
75
69
|
# @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
|
76
70
|
# @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions guide
|
77
71
|
# @api public
|
78
|
-
def initialize(
|
79
|
-
|
80
|
-
# we just use default channel from it. MK.
|
81
|
-
@channel = channel_from(channel_or_connection)
|
72
|
+
def initialize(channel, type, name, opts = {})
|
73
|
+
@channel = channel
|
82
74
|
@name = name
|
83
75
|
@type = type
|
84
76
|
@options = self.class.add_default_options(name, opts)
|
data/lib/bunny/queue.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "bunny/compatibility"
|
2
1
|
require "bunny/get_response"
|
3
2
|
|
4
3
|
module Bunny
|
@@ -8,9 +7,6 @@ module Bunny
|
|
8
7
|
# @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions guide
|
9
8
|
class Queue
|
10
9
|
|
11
|
-
include Bunny::Compatibility
|
12
|
-
|
13
|
-
|
14
10
|
#
|
15
11
|
# API
|
16
12
|
#
|
@@ -22,8 +18,7 @@ module Bunny
|
|
22
18
|
# @return [Hash] Options this queue was created with
|
23
19
|
attr_reader :options
|
24
20
|
|
25
|
-
# @param [Bunny::Channel]
|
26
|
-
# backwards compatibility with 0.8.
|
21
|
+
# @param [Bunny::Channel] channel Channel this queue will use.
|
27
22
|
# @param [String] name Queue name. Pass an empty string to make RabbitMQ generate a unique one.
|
28
23
|
# @param [Hash] opts Queue properties
|
29
24
|
#
|
@@ -36,10 +31,10 @@ module Bunny
|
|
36
31
|
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
|
37
32
|
# @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions guide
|
38
33
|
# @api public
|
39
|
-
def initialize(
|
34
|
+
def initialize(channel, name = AMQ::Protocol::EMPTY_STRING, opts = {})
|
40
35
|
# old Bunny versions pass a connection here. In that case,
|
41
36
|
# we just use default channel from it. MK.
|
42
|
-
@channel =
|
37
|
+
@channel = channel
|
43
38
|
@name = name
|
44
39
|
@options = self.class.add_default_options(name, opts)
|
45
40
|
@consumers = Hash.new
|
@@ -152,6 +147,7 @@ module Bunny
|
|
152
147
|
#
|
153
148
|
# @param [Hash] opts Options
|
154
149
|
#
|
150
|
+
# @option opts [Boolean] :ack (false) [DEPRECATED] Use :manual_ack instead
|
155
151
|
# @option opts [Boolean] :manual_ack (false) Will this consumer use manual acknowledgements?
|
156
152
|
# @option opts [Boolean] :exclusive (false) Should this consumer be exclusive for this queue?
|
157
153
|
# @option opts [Boolean] :block (false) Should the call block calling thread?
|
@@ -163,17 +159,22 @@ module Bunny
|
|
163
159
|
# @api public
|
164
160
|
def subscribe(opts = {
|
165
161
|
:consumer_tag => @channel.generate_consumer_tag,
|
166
|
-
:
|
162
|
+
:manual_ack => false,
|
167
163
|
:exclusive => false,
|
168
164
|
:block => false,
|
169
165
|
:on_cancellation => nil
|
170
166
|
}, &block)
|
171
167
|
|
168
|
+
unless opts[:ack].nil?
|
169
|
+
warn "[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead."
|
170
|
+
opts[:manual_ack] = opts[:ack]
|
171
|
+
end
|
172
|
+
|
172
173
|
ctag = opts.fetch(:consumer_tag, @channel.generate_consumer_tag)
|
173
174
|
consumer = Consumer.new(@channel,
|
174
175
|
self,
|
175
176
|
ctag,
|
176
|
-
!
|
177
|
+
!opts[:manual_ack],
|
177
178
|
opts[:exclusive],
|
178
179
|
opts[:arguments])
|
179
180
|
|
@@ -208,7 +209,8 @@ module Bunny
|
|
208
209
|
|
209
210
|
# @param [Hash] opts Options
|
210
211
|
#
|
211
|
-
# @option opts [Boolean] :ack (false)
|
212
|
+
# @option opts [Boolean] :ack (false) [DEPRECATED] Use :manual_ack instead
|
213
|
+
# @option opts [Boolean] :manual_ack (false) Will the message be acknowledged manually?
|
212
214
|
#
|
213
215
|
# @return [Array] Triple of delivery info, message properties and message content.
|
214
216
|
# If the queue is empty, all three will be nils.
|
@@ -229,7 +231,12 @@ module Bunny
|
|
229
231
|
#
|
230
232
|
# puts "This is the message: " + payload + "\n\n"
|
231
233
|
# conn.close
|
232
|
-
def pop(opts = {:
|
234
|
+
def pop(opts = {:manual_ack => false}, &block)
|
235
|
+
unless opts[:ack].nil?
|
236
|
+
warn "[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead."
|
237
|
+
opts[:manual_ack] = opts[:ack]
|
238
|
+
end
|
239
|
+
|
233
240
|
get_response, properties, content = @channel.basic_get(@name, opts)
|
234
241
|
|
235
242
|
if block
|