bunny 2.14.4 → 2.19.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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -12
  3. data/lib/bunny/channel.rb +2 -2
  4. data/lib/bunny/queue.rb +0 -3
  5. data/lib/bunny/reader_loop.rb +11 -11
  6. data/lib/bunny/session.rb +42 -9
  7. data/lib/bunny/transport.rb +12 -11
  8. data/lib/bunny/version.rb +1 -1
  9. data/spec/higher_level_api/integration/basic_cancel_spec.rb +4 -4
  10. data/spec/higher_level_api/integration/basic_consume_spec.rb +17 -9
  11. data/spec/higher_level_api/integration/connection_spec.rb +26 -0
  12. data/spec/higher_level_api/integration/tls_connection_spec.rb +194 -189
  13. data/spec/issues/issue202_spec.rb +1 -1
  14. data/spec/issues/issue609_spec.rb +84 -0
  15. data/spec/issues/issue78_spec.rb +2 -2
  16. data/spec/lower_level_api/integration/basic_cancel_spec.rb +1 -1
  17. data/spec/lower_level_api/integration/basic_consume_spec.rb +8 -8
  18. data/spec/unit/exchange_recovery_spec.rb +2 -2
  19. metadata +37 -95
  20. data/.github/ISSUE_TEMPLATE.md +0 -18
  21. data/.gitignore +0 -28
  22. data/.rspec +0 -1
  23. data/.travis.yml +0 -32
  24. data/.yardopts +0 -8
  25. data/CONTRIBUTING.md +0 -132
  26. data/ChangeLog.md +0 -2103
  27. data/Gemfile +0 -55
  28. data/LICENSE +0 -21
  29. data/Rakefile +0 -54
  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/bunny.gemspec +0 -34
  42. data/docker-compose.yml +0 -28
  43. data/docker/Dockerfile +0 -24
  44. data/docker/apt/preferences.d/erlang +0 -3
  45. data/docker/apt/sources.list.d/bintray.rabbitmq.list +0 -2
  46. data/docker/docker-entrypoint.sh +0 -26
  47. data/docker/rabbitmq.conf +0 -29
  48. data/examples/connection/authentication_failure.rb +0 -16
  49. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  50. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  51. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  52. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  53. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  54. data/examples/connection/channel_level_exception.rb +0 -27
  55. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  56. data/examples/connection/heartbeat.rb +0 -17
  57. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  58. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  59. data/examples/connection/unknown_host.rb +0 -16
  60. data/examples/consumers/high_and_low_priority.rb +0 -50
  61. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  62. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  63. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  64. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  65. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  66. data/examples/guides/extensions/basic_nack.rb +0 -33
  67. data/examples/guides/extensions/connection_blocked.rb +0 -35
  68. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  69. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  70. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  71. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  72. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  73. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  74. data/examples/guides/extensions/queue_lease.rb +0 -26
  75. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  76. data/examples/guides/getting_started/blabbr.rb +0 -27
  77. data/examples/guides/getting_started/hello_world.rb +0 -22
  78. data/examples/guides/getting_started/weathr.rb +0 -49
  79. data/examples/guides/queues/one_off_consumer.rb +0 -25
  80. data/examples/guides/queues/redeliveries.rb +0 -81
  81. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  82. data/repl +0 -3
  83. data/spec/tls/generate-server-cert.sh +0 -8
  84. data/spec/tls/server-openssl.cnf +0 -10
  85. data/spec/tls/server.csr +0 -16
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "bundler"
5
- Bundler.setup
6
-
7
- $:.unshift(File.expand_path("../../../lib", __FILE__))
8
-
9
- require 'bunny'
10
-
11
- conn = Bunny.new(heartbeat_timeout: 8)
12
- conn.start
13
-
14
- ch = conn.create_channel
15
- x = ch.topic("bunny.examples.recovery.topic", :durable => false)
16
- q = ch.queue("", :durable => false)
17
-
18
- q.bind(x, :routing_key => "abc").bind(x, :routing_key => "def")
19
-
20
- q.subscribe do |delivery_info, metadata, payload|
21
- puts "Consumed #{payload}"
22
- end
23
-
24
- loop do
25
- sleep 2
26
- data = rand.to_s
27
- rk = ["abc", "def"].sample
28
-
29
- begin
30
- x.publish(rand.to_s, :routing_key => rk)
31
- # happens when a message is published before the connection
32
- # is recovered
33
- rescue Bunny::ConnectionClosedError => e
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "bundler"
5
- Bundler.setup
6
-
7
- $:.unshift(File.expand_path("../../../lib", __FILE__))
8
-
9
- require 'bunny'
10
-
11
- conn = Bunny.new(heartbeat_timeout: 8)
12
- conn.start
13
-
14
- begin
15
- ch2 = conn.create_channel
16
- q = "bunny.examples.recovery.q#{rand}"
17
-
18
- ch2.queue_declare(q, :durable => false)
19
- ch2.queue_declare(q, :durable => true)
20
- rescue Bunny::PreconditionFailed => e
21
- puts "Channel-level exception! Code: #{e.channel_close.reply_code}, message: #{e.channel_close.reply_text}"
22
- ensure
23
- conn.create_channel.queue_delete(q)
24
- end
25
-
26
- puts "Disconnecting..."
27
- conn.close
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "bundler"
5
- Bundler.setup
6
-
7
- $:.unshift(File.expand_path("../../../lib", __FILE__))
8
-
9
- require 'bunny'
10
-
11
- conn = Bunny.new(heartbeat_timeout: 8, automatically_recover: false)
12
- conn.start
13
-
14
- ch = conn.create_channel
15
- x = ch.topic("bunny.examples.recovery.topic", :durable => false)
16
- q = ch.queue("bunny.examples.recovery.client_named_queue2", :durable => true)
17
- q.purge
18
-
19
- q.bind(x, :routing_key => "abc").bind(x, :routing_key => "def")
20
-
21
- loop do
22
- sleep 1.5
23
- body = rand.to_s
24
- puts "Published #{body}"
25
- x.publish(body, :routing_key => ["abc", "def"].sample)
26
-
27
- sleep 1.5
28
- _, _, payload = q.pop
29
- if payload
30
- puts "Consumed #{payload}"
31
- else
32
- puts "Consumed nothing"
33
- end
34
- end
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "bundler"
5
- Bundler.setup
6
-
7
- $:.unshift(File.expand_path("../../../lib", __FILE__))
8
-
9
- require 'bunny'
10
-
11
-
12
- conn = Bunny.new(:heartbeat_timeout => 2)
13
- conn.start
14
-
15
- c = conn.create_channel
16
-
17
- sleep 10
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'bunny'
3
-
4
- Bundler.setup
5
-
6
- begin
7
- connection = Bunny.new(:automatically_recover => false)
8
- connection.start
9
-
10
- ch = connection.channel
11
- q = ch.queue("manually_reconnecting_consumer", :exclusive => true)
12
-
13
- q.subscribe(:block => true) do |_, _, payload|
14
- puts "Consumed #{payload}"
15
- end
16
- rescue Bunny::NetworkFailure => e
17
- ch.maybe_kill_consumer_work_pool!
18
-
19
- sleep 10
20
- puts "Recovering manually..."
21
-
22
- retry
23
- end
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'bunny'
3
-
4
- Bundler.setup
5
-
6
- begin
7
- connection = Bunny.new(:automatically_recover => false)
8
- connection.start
9
-
10
- ch = connection.channel
11
- x = ch.default_exchange
12
-
13
- loop do
14
- 10.times do |i|
15
- print "."
16
- x.publish("")
17
- end
18
-
19
- sleep 3.0
20
- end
21
- rescue Bunny::NetworkFailure => e
22
- ch.maybe_kill_consumer_work_pool!
23
-
24
- sleep 10
25
- puts "Recovering manually..."
26
-
27
- retry
28
- end
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "bundler"
5
- Bundler.setup
6
-
7
- $:.unshift(File.expand_path("../../../lib", __FILE__))
8
-
9
- require 'bunny'
10
-
11
- begin
12
- conn = Bunny.new("amqp://guest:guest@aksjhdkajshdkj.example82737.com")
13
- conn.start
14
- rescue Bunny::TCPConnectionFailed => e
15
- puts "Connection to #{conn.hostname} failed"
16
- end
@@ -1,50 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "bundler"
5
- Bundler.setup
6
-
7
- $:.unshift(File.expand_path("../../../lib", __FILE__))
8
-
9
- require 'bunny'
10
-
11
- HIGH_PRIORITY_Q = "bunny.examples.priority.hilo.high"
12
- LOW_PRIORITY_Q = "bunny.examples.priority.hilo.low"
13
-
14
- conn = Bunny.new(heartbeat_timeout: 8)
15
- conn.start
16
-
17
- ch1 = conn.create_channel
18
- ch2 = conn.create_channel
19
- hi_q = ch1.queue(HIGH_PRIORITY_Q, :durable => false)
20
- lo_q = ch2.queue(LOW_PRIORITY_Q, :durable => false)
21
-
22
- ch3 = conn.create_channel
23
- x = ch3.default_exchange
24
-
25
- # create a backlog of low priority messages
26
- 30.times do
27
- x.publish(rand.to_s, :routing_key => LOW_PRIORITY_Q)
28
- end
29
-
30
- # and a much smaller one of high priority messages
31
- 3.times do
32
- x.publish(rand.to_s, :routing_key => HIGH_PRIORITY_Q)
33
- end
34
-
35
- hi_q.subscribe do |delivery_info, metadata, payload|
36
- puts "[high] Consumed #{payload}"
37
- end
38
-
39
- lo_q.subscribe do |delivery_info, metadata, payload|
40
- puts "[low] Consumed #{payload}"
41
- end
42
-
43
- loop do
44
- sleep 0.5
45
- data = rand.to_s
46
- rk = [HIGH_PRIORITY_Q, LOW_PRIORITY_Q].sample
47
-
48
- x.publish(data, :routing_key => rk)
49
- puts "Published #{data}, routing key: #{rk}"
50
- end
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Direct exchange routing"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.direct("examples.imaging")
15
-
16
- q1 = ch.queue("", :auto_delete => true).bind(x, :routing_key => "resize")
17
- q1.subscribe do |delivery_info, properties, payload|
18
- puts "[consumer] #{q1.name} received a 'resize' message"
19
- end
20
- q2 = ch.queue("", :auto_delete => true).bind(x, :routing_key => "watermark")
21
- q2.subscribe do |delivery_info, properties, payload|
22
- puts "[consumer] #{q2.name} received a 'watermark' message"
23
- end
24
-
25
- # just an example
26
- data = rand.to_s
27
- x.publish(data, :routing_key => "resize")
28
- x.publish(data, :routing_key => "watermark")
29
-
30
- sleep 0.5
31
- x.delete
32
- q1.delete
33
- q2.delete
34
-
35
- puts "Disconnecting..."
36
- conn.close
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Fanout exchange routing"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.fanout("examples.pings")
15
-
16
- 10.times do |i|
17
- q = ch.queue("", :auto_delete => true).bind(x)
18
- q.subscribe do |delivery_info, properties, payload|
19
- puts "[consumer] #{q.name} received a message: #{payload}"
20
- end
21
- end
22
-
23
- x.publish("Ping")
24
-
25
- sleep 0.5
26
- x.delete
27
- puts "Disconnecting..."
28
- conn.close
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Headers exchange routing"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.headers("headers")
15
-
16
- q1 = ch.queue("", :exclusive => true).bind(x, :arguments => {"os" => "linux", "cores" => 8, "x-match" => "all"})
17
- q2 = ch.queue("", :exclusive => true).bind(x, :arguments => {"os" => "osx", "cores" => 4, "x-match" => "any"})
18
-
19
- q1.subscribe do |delivery_info, properties, content|
20
- puts "#{q1.name} received #{content}"
21
- end
22
- q2.subscribe do |delivery_info, properties, content|
23
- puts "#{q2.name} received #{content}"
24
- end
25
-
26
- x.publish("8 cores/Linux", :headers => {"os" => "linux", "cores" => 8})
27
- x.publish("8 cores/OS X", :headers => {"os" => "osx", "cores" => 8})
28
- x.publish("4 cores/Linux", :headers => {"os" => "linux", "cores" => 4})
29
-
30
- sleep 0.5
31
- conn.close
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Publishing messages as mandatory"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.default_exchange
15
-
16
- x.on_return do |return_info, properties, content|
17
- puts "Got a returned message: #{content}"
18
- end
19
-
20
- q = ch.queue("", :exclusive => true)
21
- q.subscribe do |delivery_info, properties, content|
22
- puts "Consumed a message: #{content}"
23
- end
24
-
25
- x.publish("This will NOT be returned", :mandatory => true, :routing_key => q.name)
26
- x.publish("This will be returned", :mandatory => true, :routing_key => "akjhdfkjsh#{rand}")
27
-
28
- sleep 0.5
29
- puts "Disconnecting..."
30
- conn.close
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- STDOUT.sync = true
8
-
9
- puts "=> Demonstrating alternate exchanges"
10
- puts
11
-
12
- conn = Bunny.new
13
- conn.start
14
-
15
- ch = conn.create_channel
16
- x1 = ch.fanout("bunny.examples.ae.exchange1", :auto_delete => true, :durable => false)
17
- x2 = ch.fanout("bunny.examples.ae.exchange2", :auto_delete => true, :durable => false, :arguments => {
18
- "alternate-exchange" => x1.name
19
- })
20
- q = ch.queue("", :exclusive => true)
21
- q.bind(x1)
22
-
23
- x2.publish("")
24
-
25
- sleep 0.2
26
- puts "Queue #{q.name} now has #{q.message_count} message in it"
27
-
28
- sleep 0.7
29
- puts "Disconnecting..."
30
- conn.close
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating basic.nack"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- q = ch.queue("", :exclusive => true)
15
-
16
- 20.times do
17
- q.publish("")
18
- end
19
-
20
- 20.times do
21
- delivery_info, _, _ = q.pop(:manual_ack => true)
22
-
23
- if delivery_info.delivery_tag == 20
24
- # requeue them all at once with basic.nack
25
- ch.nack(delivery_info.delivery_tag, true, true)
26
- end
27
- end
28
-
29
- puts "Queue #{q.name} still has #{q.message_count} messages in it"
30
-
31
- sleep 0.7
32
- puts "Disconnecting..."
33
- conn.close
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating connection.blocked"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.fanout("amq.fanout")
15
-
16
- # This example requires high memory watermark to be set
17
- # really low to demonstrate blocking.
18
- #
19
- # rabbitmqctl set_vm_memory_high_watermark 0.00000001
20
- #
21
- # should do it.
22
-
23
- conn.on_blocked do |connection_blocked|
24
- puts "Connection is blocked. Reason: #{connection_blocked.reason}"
25
- end
26
-
27
- conn.on_unblocked do |connection_unblocked|
28
- puts "Connection is unblocked."
29
- end
30
-
31
- x.publish("z" * 1024 * 1024 * 16)
32
-
33
- sleep 120.0
34
- puts "Disconnecting..."
35
- conn.close