bunny 2.7.4 → 2.22.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.
Files changed (156) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +61 -35
  3. data/lib/bunny/channel.rb +186 -50
  4. data/lib/bunny/channel_id_allocator.rb +3 -1
  5. data/lib/bunny/consumer.rb +2 -2
  6. data/lib/bunny/consumer_work_pool.rb +2 -1
  7. data/lib/bunny/cruby/socket.rb +3 -0
  8. data/lib/bunny/cruby/ssl_socket.rb +6 -1
  9. data/lib/bunny/delivery_info.rb +1 -1
  10. data/lib/bunny/heartbeat_sender.rb +2 -1
  11. data/lib/bunny/jruby/ssl_socket.rb +5 -0
  12. data/lib/bunny/queue.rb +36 -8
  13. data/lib/bunny/reader_loop.rb +22 -10
  14. data/lib/bunny/session.rb +152 -65
  15. data/lib/bunny/test_kit.rb +14 -0
  16. data/lib/bunny/transport.rb +132 -49
  17. data/lib/bunny/version.rb +1 -1
  18. data/lib/bunny.rb +45 -4
  19. metadata +37 -225
  20. data/.github/ISSUE_TEMPLATE.md +0 -18
  21. data/.gitignore +0 -28
  22. data/.rspec +0 -1
  23. data/.travis.yml +0 -20
  24. data/.yardopts +0 -8
  25. data/CONTRIBUTING.md +0 -111
  26. data/ChangeLog.md +0 -1831
  27. data/Gemfile +0 -53
  28. data/LICENSE +0 -21
  29. data/Rakefile +0 -46
  30. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  31. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  32. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  33. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  34. data/benchmarks/channel_open.rb +0 -28
  35. data/benchmarks/mutex_and_monitor.rb +0 -42
  36. data/benchmarks/queue_declare.rb +0 -29
  37. data/benchmarks/queue_declare_and_bind.rb +0 -29
  38. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  39. data/benchmarks/synchronized_sorted_set.rb +0 -53
  40. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  41. data/bin/ci/before_build +0 -46
  42. data/bunny.gemspec +0 -35
  43. data/docker/Dockerfile +0 -16
  44. data/docker/docker-entrypoint.sh +0 -37
  45. data/docker-compose.yml +0 -18
  46. data/examples/connection/authentication_failure.rb +0 -16
  47. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  48. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  49. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  50. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  51. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  52. data/examples/connection/channel_level_exception.rb +0 -27
  53. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  54. data/examples/connection/heartbeat.rb +0 -17
  55. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  56. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  57. data/examples/connection/unknown_host.rb +0 -16
  58. data/examples/consumers/high_and_low_priority.rb +0 -50
  59. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  60. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  61. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  62. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  63. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  64. data/examples/guides/extensions/basic_nack.rb +0 -33
  65. data/examples/guides/extensions/connection_blocked.rb +0 -35
  66. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  67. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  68. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  69. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  70. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  71. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  72. data/examples/guides/extensions/queue_lease.rb +0 -26
  73. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  74. data/examples/guides/getting_started/blabbr.rb +0 -27
  75. data/examples/guides/getting_started/hello_world.rb +0 -22
  76. data/examples/guides/getting_started/weathr.rb +0 -49
  77. data/examples/guides/queues/one_off_consumer.rb +0 -25
  78. data/examples/guides/queues/redeliveries.rb +0 -81
  79. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  80. data/repl +0 -3
  81. data/spec/config/enabled_plugins +0 -1
  82. data/spec/config/rabbitmq.config +0 -19
  83. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
  84. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
  85. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -349
  86. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  87. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -80
  88. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
  89. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
  90. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
  91. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
  92. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  93. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
  94. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  95. data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -471
  96. data/spec/higher_level_api/integration/connection_spec.rb +0 -559
  97. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
  98. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  99. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
  100. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  101. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
  102. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  103. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  104. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  105. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -49
  106. data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
  107. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  108. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  109. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -191
  110. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
  111. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  112. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -221
  113. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  114. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  115. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  116. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  117. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  118. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -222
  119. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  120. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  121. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  122. data/spec/issues/issue100_spec.rb +0 -42
  123. data/spec/issues/issue141_spec.rb +0 -43
  124. data/spec/issues/issue202_spec.rb +0 -15
  125. data/spec/issues/issue224_spec.rb +0 -40
  126. data/spec/issues/issue465_spec.rb +0 -32
  127. data/spec/issues/issue78_spec.rb +0 -72
  128. data/spec/issues/issue83_spec.rb +0 -30
  129. data/spec/issues/issue97_attachment.json +0 -1
  130. data/spec/issues/issue97_spec.rb +0 -175
  131. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
  132. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
  133. data/spec/spec_helper.rb +0 -51
  134. data/spec/stress/channel_close_stress_spec.rb +0 -64
  135. data/spec/stress/channel_open_stress_spec.rb +0 -84
  136. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  137. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
  138. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
  139. data/spec/stress/connection_open_close_spec.rb +0 -52
  140. data/spec/stress/long_running_consumer_spec.rb +0 -84
  141. data/spec/tls/ca_certificate.pem +0 -29
  142. data/spec/tls/ca_key.pem +0 -52
  143. data/spec/tls/client_certificate.pem +0 -29
  144. data/spec/tls/client_key.pem +0 -51
  145. data/spec/tls/generate-server-cert.sh +0 -8
  146. data/spec/tls/server-openssl.cnf +0 -10
  147. data/spec/tls/server.csr +0 -16
  148. data/spec/tls/server_certificate.pem +0 -29
  149. data/spec/tls/server_key.pem +0 -51
  150. data/spec/unit/bunny_spec.rb +0 -15
  151. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  152. data/spec/unit/concurrent/condition_spec.rb +0 -82
  153. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  154. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  155. data/spec/unit/exchange_recovery_spec.rb +0 -39
  156. data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,54 +0,0 @@
1
- require "spec_helper"
2
- require "set"
3
-
4
- describe Bunny::Queue, "#subscribe_with" do
5
- let(:connection) do
6
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
7
- c.start
8
- c
9
- end
10
-
11
- after :each do
12
- connection.close if connection.open?
13
- end
14
-
15
- context "with explicit acknowledgements mode" do
16
- class ExampleConsumer < Bunny::Consumer
17
- def cancelled?
18
- @cancelled
19
- end
20
-
21
- def handle_cancellation(_)
22
- @cancelled = true
23
- end
24
-
25
- def call(delivery_info, metadata, payload)
26
- # no-op
27
- end
28
- end
29
-
30
- # demonstrates that manual acknowledgement mode is actually
31
- # used. MK.
32
- it "requeues messages on channel closure" do
33
- ch1 = connection.create_channel
34
- ch2 = connection.create_channel
35
- q1 = ch1.queue("bunny.tests.consumer_object1", exclusive: true)
36
- q2 = ch2.queue("bunny.tests.consumer_object1", exclusive: true)
37
- ec = ExampleConsumer.new(ch1, q1, "", false)
38
- x = ch2.default_exchange
39
-
40
- t = Thread.new do
41
- 50.times do
42
- x.publish("hello", routing_key: q2.name)
43
- end
44
- end
45
- t.abort_on_exception = true
46
-
47
- q1.subscribe_with(ec, manual_ack: true)
48
- sleep 2
49
- ch1.close
50
-
51
- expect(q2.message_count).to eq 50
52
- end
53
- end
54
- end
@@ -1,80 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Queue, "#pop" do
4
- let(:connection) do
5
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
6
- automatically_recover: false)
7
- c.start
8
- c
9
- end
10
-
11
- after :each do
12
- connection.close if connection.open?
13
- end
14
-
15
- context "with all defaults" do
16
- it "fetches a messages which is automatically acknowledged" do
17
- ch = connection.create_channel
18
-
19
- q = ch.queue("", exclusive: true)
20
- x = ch.default_exchange
21
-
22
- msg = "xyzzy"
23
- x.publish(msg, routing_key: q.name)
24
-
25
- sleep(0.5)
26
- get_ok, properties, content = q.pop
27
- expect(get_ok).to be_kind_of(Bunny::GetResponse)
28
- expect(properties).to be_kind_of(Bunny::MessageProperties)
29
- expect(properties.content_type).to eq("application/octet-stream")
30
- expect(get_ok.routing_key).to eq(q.name)
31
- expect(get_ok.delivery_tag).to be_kind_of(Bunny::VersionedDeliveryTag)
32
- expect(content).to eq(msg)
33
- expect(q.message_count).to eq 0
34
-
35
- ch.close
36
- end
37
- end
38
-
39
-
40
- context "with an empty queue" do
41
- it "returns an empty response" do
42
- ch = connection.create_channel
43
-
44
- q = ch.queue("", exclusive: true)
45
- q.purge
46
-
47
- get_empty, properties, content = q.pop
48
- expect(get_empty).to eq(nil)
49
- expect(properties).to eq(nil)
50
- expect(content).to eq(nil)
51
- expect(q.message_count).to eq 0
52
-
53
- ch.close
54
- end
55
- end
56
- end
57
-
58
-
59
- describe Bunny::Channel, "#basic_get" do
60
- let(:connection) do
61
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
62
- automatically_recover: false, continuation_timeout: 3000)
63
- c.start
64
- c
65
- end
66
-
67
- after :each do
68
- connection.close if connection.open?
69
- end
70
-
71
- context "with a non-existent queue" do
72
- it "throws a NOT_FOUND" do
73
- ch = connection.create_channel
74
-
75
- expect do
76
- ch.basic_get "non_existent_#{rand.to_s}"
77
- end.to raise_error(Bunny::NotFound)
78
- end
79
- end
80
- end
@@ -1,82 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#nack" 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
- subject do
15
- connection.create_channel
16
- end
17
-
18
- context "with requeue = false" do
19
- it "rejects a message" do
20
- q = subject.queue("bunny.basic.nack.with-requeue-false", exclusive: true)
21
- x = subject.default_exchange
22
-
23
- x.publish("bunneth", routing_key: q.name)
24
- sleep(0.5)
25
- expect(q.message_count).to eq 1
26
- delivery_info, _, content = q.pop(manual_ack: true)
27
-
28
- subject.nack(delivery_info.delivery_tag, false, false)
29
- sleep(0.5)
30
- subject.close
31
-
32
- ch = connection.create_channel
33
- q = ch.queue("bunny.basic.nack.with-requeue-false", exclusive: true)
34
- expect(q.message_count).to eq 0
35
- ch.close
36
- end
37
- end
38
-
39
- context "with multiple = true" do
40
- it "rejects multiple messages" do
41
- q = subject.queue("bunny.basic.nack.with-requeue-true-multi-true", exclusive: true)
42
- x = subject.default_exchange
43
-
44
- 3.times do
45
- x.publish("bunneth", routing_key: q.name)
46
- end
47
- sleep(0.5)
48
- expect(q.message_count).to eq 3
49
- _, _, _ = q.pop(manual_ack: true)
50
- _, _, _ = q.pop(manual_ack: true)
51
- delivery_info, _, content = q.pop(manual_ack: true)
52
-
53
- subject.nack(delivery_info.delivery_tag, true, true)
54
- sleep(0.5)
55
- expect(q.message_count).to eq 3
56
-
57
- subject.close
58
- end
59
- end
60
-
61
-
62
- context "with an invalid (random) delivery tag" do
63
- it "causes a channel-level error" do
64
- q = subject.queue("bunny.basic.nack.unknown-delivery-tag", exclusive: true)
65
- x = subject.default_exchange
66
-
67
- x.publish("bunneth", routing_key: q.name)
68
- sleep(0.25)
69
- expect(q.message_count).to eq 1
70
- _, _, content = q.pop(manual_ack: true)
71
-
72
- subject.on_error do |ch, channel_close|
73
- @channel_close = channel_close
74
- end
75
- subject.nack(82, false, true)
76
-
77
- sleep 0.5
78
-
79
- expect(@channel_close.reply_text).to eq "PRECONDITION_FAILED - unknown delivery tag 82"
80
- end
81
- end
82
- end
@@ -1,74 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Published message" 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 all default delivery and a 254 character long routing key" do
15
- it "routes the messages" do
16
- ch = connection.create_channel
17
-
18
- q = ch.queue("", exclusive: true)
19
- x = ch.fanout("amq.fanout")
20
- q.bind(x)
21
-
22
- rk = "a" * 254
23
- x.publish("xyzzy", routing_key: rk, persistent: true)
24
-
25
- sleep(1)
26
- expect(q.message_count).to eq 1
27
-
28
- _, _, payload = q.pop
29
-
30
- expect(payload).to eq "xyzzy"
31
-
32
- ch.close
33
- end
34
- end
35
-
36
- context "with all default delivery and a 255 character long routing key" do
37
- it "routes the messages" do
38
- ch = connection.create_channel
39
-
40
- q = ch.queue("", exclusive: true)
41
- x = ch.fanout("amq.fanout")
42
- q.bind(x)
43
-
44
- rk = "a" * 255
45
- x.publish("xyzzy", routing_key: rk, persistent: true)
46
-
47
- sleep(1)
48
- expect(q.message_count).to eq 1
49
-
50
- _, _, payload = q.pop
51
-
52
- expect(payload).to eq "xyzzy"
53
-
54
- ch.close
55
- end
56
- end
57
-
58
- context "with all default delivery and a 256 character long routing key" do
59
- it "fails with a connection exception" do
60
- ch = connection.create_channel
61
-
62
- q = ch.queue("", exclusive: true)
63
- x = ch.fanout("amq.fanout")
64
- q.bind(x)
65
-
66
- rk = "a" * 256
67
- expect do
68
- x.publish("xyzzy", routing_key: rk, persistent: true)
69
- end.to raise_error(ArgumentError)
70
-
71
- ch.close
72
- end
73
- end
74
- end
@@ -1,57 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#prefetch" 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 "with a positive integer < 65535" do
15
- it "sets that prefetch level via basic.qos" do
16
- ch = connection.create_channel
17
- expect(ch.prefetch_count).not_to eq 10
18
- expect(ch.prefetch_global).to be_nil
19
- expect(ch.prefetch(10)).to be_instance_of(AMQ::Protocol::Basic::QosOk)
20
- expect(ch.prefetch_count).to eq 10
21
- expect(ch.prefetch_global).to be false
22
- end
23
-
24
- it "sets that prefetch global via basic.qos" do
25
- ch = connection.create_channel
26
- expect(ch.prefetch_count).not_to eq 42
27
- expect(ch.prefetch_global).to be_nil
28
- expect(ch.prefetch(42, true)).to be_instance_of(AMQ::Protocol::Basic::QosOk)
29
- expect(ch.prefetch_count).to eq 42
30
- expect(ch.prefetch_global).to be true
31
- end
32
- end
33
-
34
- context "with a positive integer > 65535" do
35
- it "raises an ArgumentError" do
36
- ch = connection.create_channel
37
- expect {
38
- ch.prefetch(100_000)
39
- }.to raise_error(
40
- ArgumentError,
41
- "prefetch count must be no greater than #{Bunny::Channel::MAX_PREFETCH_COUNT}, given: 100000"
42
- )
43
- end
44
- end
45
-
46
- context "with a negative integer" do
47
- it "raises an ArgumentError" do
48
- ch = connection.create_channel
49
- expect {
50
- ch.prefetch(-2)
51
- }.to raise_error(
52
- ArgumentError,
53
- "prefetch count must be a positive integer, given: -2"
54
- )
55
- end
56
- end
57
- end
@@ -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,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "when closed" 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
- it "releases the id" do
15
- ch = connection.create_channel
16
- n = ch.number
17
-
18
- expect(ch).to be_open
19
- ch.close
20
- expect(ch).to be_closed
21
-
22
- # a new channel with the same id can be created
23
- connection.create_channel(n)
24
- end
25
- 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