bunny 2.17.0 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/bunny/session.rb +22 -4
  4. data/lib/bunny/transport.rb +7 -6
  5. data/lib/bunny/version.rb +1 -1
  6. data/spec/higher_level_api/integration/basic_consume_spec.rb +14 -6
  7. data/spec/higher_level_api/integration/tls_connection_spec.rb +25 -32
  8. data/spec/issues/issue609_spec.rb +84 -0
  9. data/spec/lower_level_api/integration/basic_cancel_spec.rb +1 -1
  10. data/spec/lower_level_api/integration/basic_consume_spec.rb +8 -8
  11. metadata +28 -87
  12. data/.github/ISSUE_TEMPLATE.md +0 -18
  13. data/.gitignore +0 -28
  14. data/.rspec +0 -1
  15. data/.travis.yml +0 -33
  16. data/.yardopts +0 -8
  17. data/CONTRIBUTING.md +0 -132
  18. data/ChangeLog.md +0 -2129
  19. data/Gemfile +0 -55
  20. data/LICENSE +0 -21
  21. data/Rakefile +0 -54
  22. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  23. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  24. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  25. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  26. data/benchmarks/channel_open.rb +0 -28
  27. data/benchmarks/mutex_and_monitor.rb +0 -42
  28. data/benchmarks/queue_declare.rb +0 -29
  29. data/benchmarks/queue_declare_and_bind.rb +0 -29
  30. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  31. data/benchmarks/synchronized_sorted_set.rb +0 -53
  32. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  33. data/bunny.gemspec +0 -34
  34. data/docker-compose.yml +0 -28
  35. data/docker/Dockerfile +0 -24
  36. data/docker/apt/preferences.d/erlang +0 -3
  37. data/docker/apt/sources.list.d/bintray.rabbitmq.list +0 -2
  38. data/docker/docker-entrypoint.sh +0 -26
  39. data/docker/rabbitmq.conf +0 -29
  40. data/examples/connection/authentication_failure.rb +0 -16
  41. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  42. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  43. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  44. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  45. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  46. data/examples/connection/channel_level_exception.rb +0 -27
  47. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  48. data/examples/connection/heartbeat.rb +0 -17
  49. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  50. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  51. data/examples/connection/unknown_host.rb +0 -16
  52. data/examples/consumers/high_and_low_priority.rb +0 -50
  53. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  54. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  55. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  56. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  57. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  58. data/examples/guides/extensions/basic_nack.rb +0 -33
  59. data/examples/guides/extensions/connection_blocked.rb +0 -35
  60. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  61. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  62. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  63. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  64. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  65. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  66. data/examples/guides/extensions/queue_lease.rb +0 -26
  67. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  68. data/examples/guides/getting_started/blabbr.rb +0 -27
  69. data/examples/guides/getting_started/hello_world.rb +0 -22
  70. data/examples/guides/getting_started/weathr.rb +0 -49
  71. data/examples/guides/queues/one_off_consumer.rb +0 -25
  72. data/examples/guides/queues/redeliveries.rb +0 -81
  73. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  74. data/repl +0 -3
  75. data/spec/tls/generate-server-cert.sh +0 -8
  76. data/spec/tls/server-openssl.cnf +0 -10
  77. 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