bunny 2.19.0 → 2.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -32
  3. data/lib/bunny/channel.rb +86 -10
  4. data/lib/bunny/consumer.rb +2 -2
  5. data/lib/bunny/delivery_info.rb +1 -1
  6. data/lib/bunny/queue.rb +33 -2
  7. data/lib/bunny/session.rb +1 -1
  8. data/lib/bunny/transport.rb +30 -1
  9. data/lib/bunny/version.rb +1 -1
  10. data/lib/bunny.rb +45 -4
  11. metadata +4 -144
  12. data/spec/config/enabled_plugins +0 -1
  13. data/spec/config/rabbitmq.conf +0 -13
  14. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
  15. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
  16. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -357
  17. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  18. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -80
  19. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
  20. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
  21. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
  22. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
  23. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  24. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -66
  25. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  26. data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -483
  27. data/spec/higher_level_api/integration/connection_spec.rb +0 -589
  28. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
  29. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  30. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
  31. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  32. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
  33. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  34. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  35. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  36. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -49
  37. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  38. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  39. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -191
  40. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
  41. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  42. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -285
  43. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  44. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  45. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  46. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  47. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  48. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -255
  49. data/spec/higher_level_api/integration/toxiproxy_spec.rb +0 -76
  50. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  51. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  52. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  53. data/spec/issues/issue100_spec.rb +0 -42
  54. data/spec/issues/issue141_spec.rb +0 -43
  55. data/spec/issues/issue202_spec.rb +0 -15
  56. data/spec/issues/issue224_spec.rb +0 -40
  57. data/spec/issues/issue465_spec.rb +0 -32
  58. data/spec/issues/issue549_spec.rb +0 -30
  59. data/spec/issues/issue609_spec.rb +0 -84
  60. data/spec/issues/issue78_spec.rb +0 -72
  61. data/spec/issues/issue83_spec.rb +0 -30
  62. data/spec/issues/issue97_attachment.json +0 -1
  63. data/spec/issues/issue97_spec.rb +0 -175
  64. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
  65. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
  66. data/spec/spec_helper.rb +0 -47
  67. data/spec/stress/channel_close_stress_spec.rb +0 -64
  68. data/spec/stress/channel_open_stress_spec.rb +0 -84
  69. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  70. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
  71. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
  72. data/spec/stress/connection_open_close_spec.rb +0 -52
  73. data/spec/stress/merry_go_round_spec.rb +0 -105
  74. data/spec/toxiproxy_helper.rb +0 -28
  75. data/spec/unit/bunny_spec.rb +0 -15
  76. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  77. data/spec/unit/concurrent/condition_spec.rb +0 -82
  78. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  79. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  80. data/spec/unit/exchange_recovery_spec.rb +0 -39
  81. data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,152 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#reject" do
4
- let(:connection) do
5
- c = Bunny.new(username: "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
- context "with requeue = true" do
15
- it "requeues a message" do
16
- ch = connection.create_channel
17
- q = ch.queue("bunny.basic.reject.manual-acks", exclusive: true)
18
- x = ch.default_exchange
19
-
20
- x.publish("bunneth", routing_key: q.name)
21
- sleep(0.5)
22
- expect(q.message_count).to eq 1
23
- delivery_info, _, _ = q.pop(manual_ack: true)
24
-
25
- ch.reject(delivery_info.delivery_tag, true)
26
- sleep(0.5)
27
- expect(q.message_count).to eq 1
28
-
29
- ch.close
30
- end
31
- end
32
-
33
- context "with requeue = false" do
34
- it "rejects a message" do
35
- ch = connection.create_channel
36
- q = ch.queue("bunny.basic.reject.with-requeue-false", exclusive: true)
37
- x = ch.default_exchange
38
-
39
- x.publish("bunneth", routing_key: q.name)
40
- sleep(0.5)
41
- expect(q.message_count).to eq 1
42
- delivery_info, _, _ = q.pop(manual_ack: true)
43
-
44
- ch.reject(delivery_info.delivery_tag, false)
45
- sleep(0.5)
46
- ch.close
47
-
48
- ch = connection.create_channel
49
- q = ch.queue("bunny.basic.reject.with-requeue-false", exclusive: true)
50
- expect(q.message_count).to eq 0
51
- ch.close
52
- end
53
- end
54
-
55
-
56
- context "with an invalid (random) delivery tag" do
57
- it "causes a channel-level error" do
58
- ch = connection.create_channel
59
- q = ch.queue("bunny.basic.reject.unknown-delivery-tag", exclusive: true)
60
- x = ch.default_exchange
61
-
62
- x.publish("bunneth", routing_key: q.name)
63
- sleep(0.25)
64
- expect(q.message_count).to eq 1
65
- _, _, content = q.pop(manual_ack: true)
66
-
67
- ch.on_error do |ch, channel_close|
68
- @channel_close = channel_close
69
- end
70
- ch.reject(82, true)
71
-
72
- sleep 0.5
73
-
74
- expect(@channel_close.reply_text).to eq "PRECONDITION_FAILED - unknown delivery tag 82"
75
- end
76
- end
77
- end
78
-
79
- describe Bunny::Channel, "#basic_reject" do
80
- let(:connection) do
81
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
82
- c.start
83
- c
84
- end
85
-
86
- after :each do
87
- connection.close if connection.open?
88
- end
89
-
90
- context "with requeue = true" do
91
- it "requeues a message" do
92
- ch = connection.create_channel
93
- q = ch.queue("bunny.basic.reject.manual-acks", exclusive: true)
94
- x = ch.default_exchange
95
-
96
- x.publish("bunneth", routing_key: q.name)
97
- sleep(0.5)
98
- expect(q.message_count).to eq 1
99
- delivery_info, _, _ = q.pop(manual_ack: true)
100
-
101
- ch.basic_reject(delivery_info.delivery_tag.to_i, true)
102
- sleep(0.5)
103
- expect(q.message_count).to eq 1
104
-
105
- ch.close
106
- end
107
- end
108
-
109
- context "with requeue = false" do
110
- it "rejects a message" do
111
- ch = connection.create_channel
112
- q = ch.queue("bunny.basic.reject.with-requeue-false", exclusive: true)
113
- x = ch.default_exchange
114
-
115
- x.publish("bunneth", routing_key: q.name)
116
- sleep(0.5)
117
- expect(q.message_count).to eq 1
118
- delivery_info, _, _ = q.pop(manual_ack: true)
119
-
120
- ch.basic_reject(delivery_info.delivery_tag.to_i, false)
121
- sleep(0.5)
122
- ch.close
123
-
124
- ch = connection.create_channel
125
- q = ch.queue("bunny.basic.reject.with-requeue-false", exclusive: true)
126
- expect(q.message_count).to eq 0
127
- ch.close
128
- end
129
- end
130
-
131
- context "with requeue = default" do
132
- it "rejects a message" do
133
- ch = connection.create_channel
134
- q = ch.queue("bunny.basic.reject.with-requeue-false", exclusive: true)
135
- x = ch.default_exchange
136
-
137
- x.publish("bunneth", routing_key: q.name)
138
- sleep(0.5)
139
- expect(q.message_count).to eq 1
140
- delivery_info, _, _ = q.pop(manual_ack: true)
141
-
142
- ch.basic_reject(delivery_info.delivery_tag.to_i)
143
- sleep(0.5)
144
- ch.close
145
-
146
- ch = connection.create_channel
147
- q = ch.queue("bunny.basic.reject.with-requeue-false", exclusive: true)
148
- expect(q.message_count).to eq 0
149
- ch.close
150
- end
151
- end
152
- end
@@ -1,33 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Exchange, "#publish" do
4
- let(:connection) do
5
- c = Bunny.new(username: "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
- context "with mandatory: true and a bad [no routes] routing key" do
16
- it "causes a message to be returned" do
17
- ch = connection.create_channel
18
- x = ch.default_exchange
19
-
20
- returned = []
21
- x.on_return do |basic_deliver, properties, content|
22
- returned << content
23
- end
24
-
25
- x.publish("xyzzy", routing_key: rand.to_s, mandatory: true)
26
- sleep 0.5
27
-
28
- expect(returned).to include("xyzzy")
29
-
30
- ch.close
31
- end
32
- end
33
- end
@@ -1,66 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel do
4
- let(:connection) do
5
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
6
- c.start
7
- c
8
- end
9
-
10
- after :each do
11
- connection.close
12
- end
13
-
14
- context "when closed" do
15
- it "releases the id" do
16
- ch = connection.create_channel
17
- n = ch.number
18
-
19
- expect(ch).to be_open
20
- ch.close
21
- expect(ch).to be_closed
22
-
23
- # a new channel with the same id can be created
24
- connection.create_channel(n)
25
- end
26
- end
27
-
28
- context "when double closed" do
29
- # bunny#528
30
- it "raises a meaningful exception" do
31
- ch = connection.create_channel
32
-
33
- expect(ch).to be_open
34
- ch.close
35
- expect(ch).to be_closed
36
-
37
- expect { ch.close }.to raise_error(Bunny::ChannelAlreadyClosed)
38
- end
39
- end
40
-
41
- context "when double closed after a channel-level protocol exception" do
42
- # bunny#528
43
- it "raises a meaningful exception" do
44
- ch = connection.create_channel
45
-
46
- s = "bunny-temp-q-#{rand}"
47
-
48
- expect(ch).to be_open
49
- ch.queue_declare(s, durable: false)
50
-
51
- expect do
52
- ch.queue_declare(s, durable: true)
53
- end.to raise_error(Bunny::PreconditionFailed)
54
-
55
- # channel.close is sent and handled concurrently with the test
56
- sleep 1
57
- expect(ch).to be_closed
58
-
59
- expect { ch.close }.to raise_error(Bunny::ChannelAlreadyClosed)
60
-
61
- cleanup_ch = connection.create_channel
62
- cleanup_ch.queue_delete(s)
63
- cleanup_ch.close
64
- end
65
- end
66
- end
@@ -1,57 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "when opened" do
4
- let(:connection) do
5
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
6
- c.start
7
- c
8
- end
9
-
10
- after :each do
11
- connection.close
12
- end
13
-
14
- context "without explicitly provided id" do
15
- it "gets an allocated id and is successfully opened" do
16
- expect(connection).to be_connected
17
- ch = connection.create_channel
18
- expect(ch).to be_open
19
-
20
- expect(ch.id).to be > 0
21
- end
22
- end
23
-
24
- context "with an explicitly provided id = 0" do
25
- it "raises ArgumentError" do
26
- expect(connection).to be_connected
27
- expect {
28
- connection.create_channel(0)
29
- }.to raise_error(ArgumentError)
30
- end
31
- end
32
-
33
-
34
- context "with explicitly provided id" do
35
- it "uses that id and is successfully opened" do
36
- ch = connection.create_channel(767)
37
- expect(connection).to be_connected
38
- expect(ch).to be_open
39
-
40
- expect(ch.id).to eq 767
41
- end
42
- end
43
-
44
-
45
-
46
- context "with explicitly provided id that is already taken" do
47
- it "reuses the channel that is already opened" do
48
- ch = connection.create_channel(767)
49
- expect(connection).to be_connected
50
- expect(ch).to be_open
51
-
52
- expect(ch.id).to eq 767
53
-
54
- expect(connection.create_channel(767)).to eq ch
55
- end
56
- end
57
- end