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,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#with_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 if connection.open?
12
- end
13
-
14
- it "closes if the block throws an exception" do
15
- ch = nil
16
- begin
17
- connection.with_channel do |wch|
18
- ch = wch
19
- raise Exception.new
20
- end
21
- rescue Exception
22
- end
23
- expect(ch).to be_closed
24
- end
25
- end
@@ -1,42 +0,0 @@
1
- require "spec_helper"
2
-
3
- unless ENV["CI"]
4
- describe Bunny::Channel, "#basic_publish" do
5
- before :all do
6
- @connection = Bunny.new(username: "bunny_gem",
7
- password: "bunny_password",
8
- vhost: "bunny_testbed",
9
- write_timeout: 0,
10
- read_timeout: 0)
11
- @connection.start
12
- end
13
-
14
- after :all do
15
- @connection.close if @connection.open?
16
- end
17
-
18
-
19
- context "when publishing thousands of messages" do
20
- let(:n) { 2_000 }
21
- let(:m) { 10 }
22
-
23
- it "successfully publishers them all" do
24
- ch = @connection.create_channel
25
-
26
- q = ch.queue("", exclusive: true)
27
- x = ch.default_exchange
28
-
29
- body = "x" * 1024
30
- m.times do |i|
31
- n.times do
32
- x.publish(body, routing_key: q.name)
33
- end
34
- puts "Published #{i * n} 1K messages..."
35
- end
36
-
37
- q.purge
38
- ch.close
39
- end
40
- end
41
- end
42
- end
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Registering 2nd exclusive consumer on queue" do
4
- before :all do
5
- @connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
6
- @connection.start
7
- end
8
-
9
- after :each do
10
- @connection.close if @connection.open?
11
- end
12
-
13
-
14
- it "raises a meaningful exception" do
15
- xs = []
16
-
17
- ch1 = @connection.create_channel
18
- ch2 = @connection.create_channel
19
- q1 = ch1.queue("", :auto_delete => true)
20
- q2 = ch2.queue(q1.name, :auto_delete => true, :passive => true)
21
-
22
- c1 = q1.subscribe(exclusive: true) do |_, _, payload|
23
- xs << payload
24
- end
25
- sleep 0.1
26
-
27
- expect do
28
- q2.subscribe(exclusive: true) do |_, _, _|
29
- end
30
- end.to raise_error(Bunny::AccessRefused)
31
-
32
- expect(ch1).to be_open
33
- expect(ch2).to be_closed
34
-
35
- q1.publish("abc")
36
- sleep 0.1
37
-
38
- # verify that the first consumer is fine
39
- expect(xs).to eq ["abc"]
40
-
41
- q1.delete
42
- end
43
- end
@@ -1,15 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Session do
4
- context "with unreachable host" do
5
- it "raises Bunny::TCPConnectionFailed" do
6
- begin
7
- conn = Bunny.new(:hostname => "192.192.192.192")
8
- conn.start
9
-
10
- fail "expected 192.192.192.192 to be unreachable"
11
- rescue Bunny::TCPConnectionFailed => e
12
- end
13
- end
14
- end
15
- end
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require "spec_helper"
3
-
4
- unless ENV["CI"]
5
- describe "Message framing implementation" do
6
- let(:connection) do
7
- c = Bunny.new(:user => "bunny_gem",
8
- password: "bunny_password",
9
- :vhost => "bunny_testbed",
10
- :port => ENV.fetch("RABBITMQ_PORT", 5672))
11
- c.start
12
- c
13
- end
14
-
15
- after :each do
16
- connection.close if connection.open?
17
- end
18
-
19
-
20
- context "with payload 272179 bytes in size" do
21
- it "successfully frames the message" do
22
- ch = connection.create_channel
23
-
24
- q = ch.queue("", exclusive: true)
25
- x = ch.default_exchange
26
-
27
- as = ("a" * 272179)
28
- x.publish(as, routing_key: q.name, persistent: true)
29
-
30
- sleep(1)
31
- expect(q.message_count).to eq 1
32
-
33
- _, _, payload = q.pop
34
- expect(payload.bytesize).to eq as.bytesize
35
-
36
- ch.close
37
- end
38
- end
39
- end
40
- end
@@ -1,32 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Bunny::Session do
5
- let(:connection) do
6
- c = Bunny.new(
7
- user: 'bunny_gem', password: 'bunny_password',
8
- vhost: 'bunny_testbed',
9
- port: ENV.fetch('RABBITMQ_PORT', 5672)
10
- )
11
- c.start
12
- c
13
- end
14
-
15
- context 'after the connection has been manually closed' do
16
- before :each do
17
- connection.close
18
- end
19
-
20
- after :each do
21
- connection.close if connection.open?
22
- end
23
-
24
- describe '#create_channel' do
25
- it 'should raise an exception' do
26
- expect {
27
- connection.create_channel
28
- }.to raise_error(Bunny::ConnectionAlreadyClosed)
29
- end
30
- end
31
- end
32
- end
@@ -1,72 +0,0 @@
1
- require "spec_helper"
2
-
3
- unless ENV["CI"]
4
- describe Bunny::Queue, "#subscribe" do
5
- before :all do
6
- @connection1 = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
7
- @connection1.start
8
- @connection2 = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
9
- @connection2.start
10
- end
11
-
12
- after :all do
13
- [@connection1, @connection2].select { |c| !!c }.each do |c|
14
- c.close if c.open?
15
- end
16
- end
17
-
18
-
19
- context "with an empty queue" do
20
- it "consumes messages" do
21
- delivered_data = []
22
-
23
- ch1 = @connection1.create_channel
24
- ch2 = @connection1.create_channel
25
-
26
- q = ch1.queue("", exclusive: true)
27
- q.subscribe(manual_ack: false, block: false) do |delivery_info, properties, payload|
28
- delivered_data << payload
29
- end
30
- sleep 0.5
31
-
32
- x = ch2.default_exchange
33
- x.publish("abc", routing_key: q.name)
34
- sleep 0.7
35
-
36
- expect(delivered_data).to eq ["abc"]
37
-
38
- ch1.close
39
- ch2.close
40
- end
41
- end
42
-
43
- context "with a non-empty queue" do
44
- let(:queue_name) { "queue#{rand}" }
45
-
46
- it "consumes messages" do
47
- delivered_data = []
48
-
49
- ch1 = @connection1.create_channel
50
- ch2 = @connection1.create_channel
51
-
52
- q = ch1.queue(queue_name, exclusive: true)
53
- x = ch2.default_exchange
54
- 3.times do |i|
55
- x.publish("data#{i}", routing_key: queue_name)
56
- end
57
- sleep 0.7
58
- expect(q.message_count).to eq 3
59
-
60
- q.subscribe(manual_ack: false, block: false) do |delivery_info, properties, payload|
61
- delivered_data << payload
62
- end
63
- sleep 0.7
64
-
65
- expect(delivered_data).to eq ["data0", "data1", "data2"]
66
-
67
- ch1.close
68
- ch2.close
69
- end
70
- end
71
- end
72
- end
@@ -1,30 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#open" do
4
- before :all do
5
- @connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
6
- @connection.start
7
- end
8
-
9
- after :all do
10
- @connection.close if @connection.open?
11
- end
12
-
13
-
14
- it "properly resets channel exception state" do
15
- ch = @connection.create_channel
16
-
17
- begin
18
- ch.queue("bunny.tests.does.not.exist", :passive => true)
19
- rescue Bunny::NotFound
20
- # expected
21
- end
22
-
23
- # reopen the channel
24
- ch.open
25
-
26
- # should not raise
27
- q = ch.queue("bunny.tests.my.queue")
28
- q.delete
29
- end
30
- end