bunny 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +8 -0
- data/lib/bunny/channel.rb +86 -65
- data/lib/bunny/version.rb +1 -1
- data/spec/issues/issue141_spec.rb +44 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de36b24ae58dc0288bf7f25d55c84d4fca21488b
|
4
|
+
data.tar.gz: eab9a6c204683443887320e9f54a29cc46c9b795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d4f79815730c98bc8df51ac8c5b0f14c1040d29d4ccf8b9dae8ded2bee0b43275364fdba63fbee6c4ef7f108ae2a6f80b269aa67b07021cedb90b5addfc0f24
|
7
|
+
data.tar.gz: 3790273b80d26a6ef6c910c59dc8d38a15e2c7d8bba9f5840598e77215e923b0d2418972acbb79ed2cfb52a0c0191700738ced4dc2923047afca9c4b387e2510
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## Changes between Bunny 0.9.7 and 0.9.8
|
2
|
+
|
3
|
+
### Exclusivity Violation for Consumers Now Raises a Reasonable Exception
|
4
|
+
|
5
|
+
When a second consumer is registered for the same queue on different channels,
|
6
|
+
a reasonable exception (`Bunny::AccessRefused`) will be raised.
|
7
|
+
|
8
|
+
|
1
9
|
## Changes between Bunny 0.9.6 and 0.9.7
|
2
10
|
|
3
11
|
### Reentrant Mutex Implementation
|
data/lib/bunny/channel.rb
CHANGED
@@ -522,13 +522,13 @@ module Bunny
|
|
522
522
|
end
|
523
523
|
|
524
524
|
m = AMQ::Protocol::Basic::Publish.encode(@id,
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
525
|
+
payload,
|
526
|
+
meta,
|
527
|
+
exchange_name,
|
528
|
+
routing_key,
|
529
|
+
meta[:mandatory],
|
530
|
+
false,
|
531
|
+
@connection.frame_max)
|
532
532
|
@connection.send_frameset_without_timeout(m, self)
|
533
533
|
|
534
534
|
self
|
@@ -765,9 +765,9 @@ module Bunny
|
|
765
765
|
def basic_nack(delivery_tag, multiple = false, requeue = false)
|
766
766
|
raise_if_no_longer_open!
|
767
767
|
@connection.send_frame(AMQ::Protocol::Basic::Nack.encode(@id,
|
768
|
-
|
769
|
-
|
770
|
-
|
768
|
+
delivery_tag,
|
769
|
+
multiple,
|
770
|
+
requeue))
|
771
771
|
|
772
772
|
nil
|
773
773
|
end
|
@@ -802,13 +802,13 @@ module Bunny
|
|
802
802
|
end
|
803
803
|
|
804
804
|
@connection.send_frame(AMQ::Protocol::Basic::Consume.encode(@id,
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
805
|
+
queue_name,
|
806
|
+
consumer_tag,
|
807
|
+
false,
|
808
|
+
no_ack,
|
809
|
+
exclusive,
|
810
|
+
false,
|
811
|
+
arguments))
|
812
812
|
|
813
813
|
begin
|
814
814
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
@@ -822,6 +822,10 @@ module Bunny
|
|
822
822
|
raise e
|
823
823
|
end
|
824
824
|
|
825
|
+
# in case there is another exclusive consumer and we get a channel.close
|
826
|
+
# response here. MK.
|
827
|
+
raise_if_channel_close!(@last_basic_consume_ok)
|
828
|
+
|
825
829
|
# covers server-generated consumer tags
|
826
830
|
add_consumer(queue_name, @last_basic_consume_ok.consumer_tag, no_ack, exclusive, arguments, &block)
|
827
831
|
|
@@ -847,13 +851,13 @@ module Bunny
|
|
847
851
|
end
|
848
852
|
|
849
853
|
@connection.send_frame(AMQ::Protocol::Basic::Consume.encode(@id,
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
854
|
+
consumer.queue_name,
|
855
|
+
consumer.consumer_tag,
|
856
|
+
false,
|
857
|
+
consumer.no_ack,
|
858
|
+
consumer.exclusive,
|
859
|
+
false,
|
860
|
+
consumer.arguments))
|
857
861
|
|
858
862
|
begin
|
859
863
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
@@ -867,6 +871,10 @@ module Bunny
|
|
867
871
|
raise e
|
868
872
|
end
|
869
873
|
|
874
|
+
# in case there is another exclusive consumer and we get a channel.close
|
875
|
+
# response here. MK.
|
876
|
+
raise_if_channel_close!(@last_basic_consume_ok)
|
877
|
+
|
870
878
|
# covers server-generated consumer tags
|
871
879
|
register_consumer(@last_basic_consume_ok.consumer_tag, consumer)
|
872
880
|
|
@@ -927,13 +935,13 @@ module Bunny
|
|
927
935
|
raise_if_no_longer_open!
|
928
936
|
|
929
937
|
@connection.send_frame(AMQ::Protocol::Queue::Declare.encode(@id,
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
938
|
+
name,
|
939
|
+
opts.fetch(:passive, false),
|
940
|
+
opts.fetch(:durable, false),
|
941
|
+
opts.fetch(:exclusive, false),
|
942
|
+
opts.fetch(:auto_delete, false),
|
943
|
+
false,
|
944
|
+
opts[:arguments]))
|
937
945
|
@last_queue_declare_ok = wait_on_continuations
|
938
946
|
|
939
947
|
raise_if_continuation_resulted_in_a_channel_error!
|
@@ -956,10 +964,10 @@ module Bunny
|
|
956
964
|
raise_if_no_longer_open!
|
957
965
|
|
958
966
|
@connection.send_frame(AMQ::Protocol::Queue::Delete.encode(@id,
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
967
|
+
name,
|
968
|
+
opts[:if_unused],
|
969
|
+
opts[:if_empty],
|
970
|
+
false))
|
963
971
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
964
972
|
@last_queue_delete_ok = wait_on_continuations
|
965
973
|
end
|
@@ -1011,11 +1019,11 @@ module Bunny
|
|
1011
1019
|
end
|
1012
1020
|
|
1013
1021
|
@connection.send_frame(AMQ::Protocol::Queue::Bind.encode(@id,
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1022
|
+
name,
|
1023
|
+
exchange_name,
|
1024
|
+
opts[:routing_key],
|
1025
|
+
false,
|
1026
|
+
opts[:arguments]))
|
1019
1027
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
1020
1028
|
@last_queue_bind_ok = wait_on_continuations
|
1021
1029
|
end
|
@@ -1047,10 +1055,10 @@ module Bunny
|
|
1047
1055
|
end
|
1048
1056
|
|
1049
1057
|
@connection.send_frame(AMQ::Protocol::Queue::Unbind.encode(@id,
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1058
|
+
name,
|
1059
|
+
exchange_name,
|
1060
|
+
opts[:routing_key],
|
1061
|
+
opts[:arguments]))
|
1054
1062
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
1055
1063
|
@last_queue_unbind_ok = wait_on_continuations
|
1056
1064
|
end
|
@@ -1082,14 +1090,14 @@ module Bunny
|
|
1082
1090
|
raise_if_no_longer_open!
|
1083
1091
|
|
1084
1092
|
@connection.send_frame(AMQ::Protocol::Exchange::Declare.encode(@id,
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
+
name,
|
1094
|
+
type.to_s,
|
1095
|
+
opts.fetch(:passive, false),
|
1096
|
+
opts.fetch(:durable, false),
|
1097
|
+
opts.fetch(:auto_delete, false),
|
1098
|
+
false,
|
1099
|
+
false,
|
1100
|
+
opts[:arguments]))
|
1093
1101
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
1094
1102
|
@last_exchange_declare_ok = wait_on_continuations
|
1095
1103
|
end
|
@@ -1112,9 +1120,9 @@ module Bunny
|
|
1112
1120
|
raise_if_no_longer_open!
|
1113
1121
|
|
1114
1122
|
@connection.send_frame(AMQ::Protocol::Exchange::Delete.encode(@id,
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1123
|
+
name,
|
1124
|
+
opts[:if_unused],
|
1125
|
+
false))
|
1118
1126
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
1119
1127
|
@last_exchange_delete_ok = wait_on_continuations
|
1120
1128
|
end
|
@@ -1154,11 +1162,11 @@ module Bunny
|
|
1154
1162
|
end
|
1155
1163
|
|
1156
1164
|
@connection.send_frame(AMQ::Protocol::Exchange::Bind.encode(@id,
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1165
|
+
destination_name,
|
1166
|
+
source_name,
|
1167
|
+
opts[:routing_key],
|
1168
|
+
false,
|
1169
|
+
opts[:arguments]))
|
1162
1170
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
1163
1171
|
@last_exchange_bind_ok = wait_on_continuations
|
1164
1172
|
end
|
@@ -1198,11 +1206,11 @@ module Bunny
|
|
1198
1206
|
end
|
1199
1207
|
|
1200
1208
|
@connection.send_frame(AMQ::Protocol::Exchange::Unbind.encode(@id,
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1209
|
+
destination_name,
|
1210
|
+
source_name,
|
1211
|
+
opts[:routing_key],
|
1212
|
+
false,
|
1213
|
+
opts[:arguments]))
|
1206
1214
|
Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
|
1207
1215
|
@last_exchange_unbind_ok = wait_on_continuations
|
1208
1216
|
end
|
@@ -1786,6 +1794,19 @@ module Bunny
|
|
1786
1794
|
raise ChannelAlreadyClosed.new("cannot use a channel that was already closed! Channel id: #{@id}", self) if closed?
|
1787
1795
|
end
|
1788
1796
|
|
1797
|
+
# @private
|
1798
|
+
def raise_if_channel_close!(method)
|
1799
|
+
if method && method.is_a?(AMQ::Protocol::Channel::Close)
|
1800
|
+
# basic.ack, basic.reject, basic.nack. MK.
|
1801
|
+
if channel_level_exception_after_operation_that_has_no_response?(method)
|
1802
|
+
@on_error.call(self, method) if @on_error
|
1803
|
+
else
|
1804
|
+
@last_channel_error = instantiate_channel_level_exception(method)
|
1805
|
+
raise @last_channel_error
|
1806
|
+
end
|
1807
|
+
end
|
1808
|
+
end
|
1809
|
+
|
1789
1810
|
# @private
|
1790
1811
|
def reset_continuations
|
1791
1812
|
@continuations = new_continuation
|
data/lib/bunny/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Registering 2nd exclusive consumer on queue" do
|
4
|
+
let(:connection) do
|
5
|
+
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
+
c.start
|
7
|
+
c
|
8
|
+
end
|
9
|
+
|
10
|
+
after :each do
|
11
|
+
connection.close if connection.open?
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
it "raises a meaningful exception" do
|
16
|
+
xs = []
|
17
|
+
|
18
|
+
ch1 = connection.create_channel
|
19
|
+
ch2 = connection.create_channel
|
20
|
+
q1 = ch1.queue("", :auto_delete => true)
|
21
|
+
q2 = ch2.queue(q1.name, :auto_delete => true, :passive => true)
|
22
|
+
|
23
|
+
c1 = q1.subscribe(:exclusive => true) do |_, _, payload|
|
24
|
+
xs << payload
|
25
|
+
end
|
26
|
+
sleep 0.1
|
27
|
+
|
28
|
+
lambda do
|
29
|
+
q2.subscribe(:exclusive => true) do |_, _, _|
|
30
|
+
end
|
31
|
+
end.should raise_error(Bunny::AccessRefused)
|
32
|
+
|
33
|
+
ch1.should be_open
|
34
|
+
ch2.should be_closed
|
35
|
+
|
36
|
+
q1.publish("abc")
|
37
|
+
sleep 0.1
|
38
|
+
|
39
|
+
# verify that the first consumer is fine
|
40
|
+
xs.should == ["abc"]
|
41
|
+
|
42
|
+
q1.delete
|
43
|
+
end
|
44
|
+
end
|
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.
|
4
|
+
version: 0.9.8
|
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-
|
15
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: amq-protocol
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- spec/higher_level_api/integration/tx_commit_spec.rb
|
163
163
|
- spec/higher_level_api/integration/tx_rollback_spec.rb
|
164
164
|
- spec/issues/issue100_spec.rb
|
165
|
+
- spec/issues/issue141_spec.rb
|
165
166
|
- spec/issues/issue78_spec.rb
|
166
167
|
- spec/issues/issue83_spec.rb
|
167
168
|
- spec/issues/issue97_attachment.json
|
@@ -250,6 +251,7 @@ test_files:
|
|
250
251
|
- spec/higher_level_api/integration/tx_commit_spec.rb
|
251
252
|
- spec/higher_level_api/integration/tx_rollback_spec.rb
|
252
253
|
- spec/issues/issue100_spec.rb
|
254
|
+
- spec/issues/issue141_spec.rb
|
253
255
|
- spec/issues/issue78_spec.rb
|
254
256
|
- spec/issues/issue83_spec.rb
|
255
257
|
- spec/issues/issue97_attachment.json
|