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,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating consumer cancellation notification"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
-
15
- module Bunny
16
- module Examples
17
- class ExampleConsumer < Bunny::Consumer
18
- def cancelled?
19
- @cancelled
20
- end
21
-
22
- def handle_cancellation(basic_cancel)
23
- puts "#{@consumer_tag} was cancelled"
24
- @cancelled = true
25
- end
26
- end
27
- end
28
- end
29
-
30
- q = ch.queue("", :exclusive => true)
31
- c = Bunny::Examples::ExampleConsumer.new(ch, q)
32
- q.subscribe_with(c)
33
-
34
- sleep 0.1
35
- q.delete
36
-
37
- sleep 0.1
38
- puts "Disconnecting..."
39
- conn.close
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating dead letter exchange"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.fanout("amq.fanout")
15
- dlx = ch.fanout("bunny.examples.dlx.exchange")
16
- q = ch.queue("", :exclusive => true, :arguments => {"x-dead-letter-exchange" => dlx.name}).bind(x)
17
- # dead letter queue
18
- dlq = ch.queue("", :exclusive => true).bind(dlx)
19
-
20
- x.publish("")
21
- sleep 0.2
22
-
23
- delivery_info, _, _ = q.pop(:manual_ack => true)
24
- puts "#{dlq.message_count} messages dead lettered so far"
25
- puts "Rejecting a message"
26
- ch.nack(delivery_info.delivery_tag)
27
- sleep 0.2
28
- puts "#{dlq.message_count} messages dead lettered so far"
29
-
30
- dlx.delete
31
- puts "Disconnecting..."
32
- conn.close
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating exchange-to-exchange bindings"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x1 = ch.fanout("bunny.examples.e2e.exchange1", :auto_delete => true, :durable => false)
15
- x2 = ch.fanout("bunny.examples.e2e.exchange2", :auto_delete => true, :durable => false)
16
- # x1 will be the source
17
- x2.bind(x1)
18
-
19
- q = ch.queue("", :exclusive => true)
20
- q.bind(x2)
21
-
22
- x1.publish("")
23
-
24
- sleep 0.2
25
- puts "Queue #{q.name} now has #{q.message_count} message in it"
26
-
27
- sleep 0.7
28
- puts "Disconnecting..."
29
- conn.close
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating per-message TTL"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.fanout("amq.fanout")
15
- q = ch.queue("", :exclusive => true).bind(x)
16
-
17
- 10.times do |i|
18
- x.publish("Message #{i}", :expiration => 1000)
19
- end
20
-
21
- sleep 0.7
22
- _, _, content1 = q.pop
23
- puts "Fetched #{content1.inspect} after 0.7 second"
24
-
25
- sleep 0.8
26
- _, _, content2 = q.pop
27
- msg = if content2
28
- content2.inspect
29
- else
30
- "nothing"
31
- end
32
- puts "Fetched #{msg} after 1.5 second"
33
-
34
- sleep 0.7
35
- puts "Closing..."
36
- conn.close
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating per-queue message TTL"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.fanout("amq.fanout")
15
- q = ch.queue("", :exclusive => true, :arguments => {"x-message-ttl" => 1000}).bind(x)
16
-
17
- 10.times do |i|
18
- x.publish("Message #{i}")
19
- end
20
-
21
- sleep 0.7
22
- _, _, content1 = q.pop
23
- puts "Fetched #{content1.inspect} after 0.7 second"
24
-
25
- sleep 0.8
26
- _, _, content2 = q.pop
27
- msg = if content2
28
- content2.inspect
29
- else
30
- "nothing"
31
- end
32
- puts "Fetched #{msg} after 1.5 second"
33
-
34
- sleep 0.7
35
- puts "Closing..."
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 "=> Demonstrating publisher confirms"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.fanout("amq.fanout")
15
- q = ch.queue("", :exclusive => true).bind(x)
16
-
17
- ch.confirm_select
18
- 1000.times do
19
- x.publish("")
20
- end
21
- ch.wait_for_confirms # blocks calling thread until all acks are received
22
-
23
- sleep 0.2
24
- puts "Received acks for all published messages. #{q.name} now has #{q.message_count} messages."
25
-
26
- sleep 0.7
27
- puts "Disconnecting..."
28
- conn.close
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating queue TTL (queue leases)"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- q = ch.queue("", :exclusive => true, :arguments => {"x-expires" => 300})
15
-
16
- sleep 0.4
17
- begin
18
- # this will raise because the queue is already deleted
19
- q.message_count
20
- rescue Bunny::NotFound => nfe
21
- puts "Got a 404 response: the queue has already been removed"
22
- end
23
-
24
- sleep 0.7
25
- puts "Closing..."
26
- conn.close
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- puts "=> Demonstrating sender-selected distribution"
8
- puts
9
-
10
- conn = Bunny.new
11
- conn.start
12
-
13
- ch = conn.create_channel
14
- x = ch.direct("bunny.examples.ssd.exchange")
15
- q1 = ch.queue("", :exclusive => true).bind(x, :routing_key => "one")
16
- q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "two")
17
- q3 = ch.queue("", :exclusive => true).bind(x, :routing_key => "three")
18
- q4 = ch.queue("", :exclusive => true).bind(x, :routing_key => "four")
19
-
20
- 10.times do |i|
21
- x.publish("Message #{i}", :routing_key => "one", :headers => {"CC" => ["two", "three"]})
22
- end
23
-
24
- sleep 0.2
25
- puts "Queue #{q1.name} now has #{q1.message_count} messages in it"
26
- puts "Queue #{q2.name} now has #{q2.message_count} messages in it"
27
- puts "Queue #{q3.name} now has #{q3.message_count} messages in it"
28
- puts "Queue #{q4.name} now has #{q4.message_count} messages in it"
29
-
30
- sleep 0.7
31
- puts "Closing..."
32
- conn.close
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
-
7
- conn = Bunny.new
8
- conn.start
9
-
10
- ch = conn.create_channel
11
- x = ch.fanout("nba.scores")
12
-
13
- ch.queue("joe", :auto_delete => true).bind(x).subscribe do |delivery_info, properties, payload|
14
- puts "#{payload} => joe"
15
- end
16
-
17
- ch.queue("aaron", :auto_delete => true).bind(x).subscribe do |delivery_info, properties, payload|
18
- puts "#{payload} => aaron"
19
- end
20
-
21
- ch.queue("bob", :auto_delete => true).bind(x).subscribe do |delivery_info, properties, payload|
22
- puts "#{payload} => bob"
23
- end
24
-
25
- x.publish("BOS 101, NYK 89").publish("ORL 85, ALT 88")
26
-
27
- conn.close
@@ -1,22 +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
- conn = Bunny.new
10
- conn.start
11
-
12
- ch = conn.create_channel
13
- q = ch.queue("bunny.examples.hello_world", :auto_delete => true)
14
-
15
- q.subscribe do |delivery_info, properties, payload|
16
- puts "Received #{payload}"
17
- end
18
-
19
- q.publish("Hello!", :routing_key => q.name)
20
-
21
- sleep 1.0
22
- conn.close
@@ -1,49 +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
- connection = Bunny.new
10
- connection.start
11
-
12
- channel = connection.create_channel
13
- # topic exchange name can be any string
14
- exchange = channel.topic("weathr", :auto_delete => true)
15
-
16
- # Subscribers.
17
- channel.queue("", :exclusive => true).bind(exchange, :routing_key => "americas.north.#").subscribe do |delivery_info, properties, payload|
18
- puts "An update for North America: #{payload}, routing key is #{delivery_info.routing_key}"
19
- end
20
- channel.queue("americas.south").bind(exchange, :routing_key => "americas.south.#").subscribe do |delivery_info, properties, payload|
21
- puts "An update for South America: #{payload}, routing key is #{delivery_info.routing_key}"
22
- end
23
- channel.queue("us.california").bind(exchange, :routing_key => "americas.north.us.ca.*").subscribe do |delivery_info, properties, payload|
24
- puts "An update for US/California: #{payload}, routing key is #{delivery_info.routing_key}"
25
- end
26
- channel.queue("us.tx.austin").bind(exchange, :routing_key => "#.tx.austin").subscribe do |delivery_info, properties, payload|
27
- puts "An update for Austin, TX: #{payload}, routing key is #{delivery_info.routing_key}"
28
- end
29
- channel.queue("it.rome").bind(exchange, :routing_key => "europe.italy.rome").subscribe do |delivery_info, properties, payload|
30
- puts "An update for Rome, Italy: #{payload}, routing key is #{delivery_info.routing_key}"
31
- end
32
- channel.queue("asia.hk").bind(exchange, :routing_key => "asia.southeast.hk.#").subscribe do |delivery_info, properties, payload|
33
- puts "An update for Hong Kong: #{payload}, routing key is #{delivery_info.routing_key}"
34
- end
35
-
36
- exchange.publish("San Diego update", :routing_key => "americas.north.us.ca.sandiego").
37
- publish("Berkeley update", :routing_key => "americas.north.us.ca.berkeley").
38
- publish("San Francisco update", :routing_key => "americas.north.us.ca.sanfrancisco").
39
- publish("New York update", :routing_key => "americas.north.us.ny.newyork").
40
- publish("São Paolo update", :routing_key => "americas.south.brazil.saopaolo").
41
- publish("Hong Kong update", :routing_key => "asia.southeast.hk.hongkong").
42
- publish("Kyoto update", :routing_key => "asia.southeast.japan.kyoto").
43
- publish("Shanghai update", :routing_key => "asia.southeast.prc.shanghai").
44
- publish("Rome update", :routing_key => "europe.italy.roma").
45
- publish("Paris update", :routing_key => "europe.france.paris")
46
-
47
- sleep 1.0
48
-
49
- connection.close
@@ -1,25 +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
- conn = Bunny.new
10
- conn.start
11
-
12
- ch = conn.create_channel
13
- q = ch.queue("bunny.examples.hello_world", :auto_delete => true)
14
-
15
- q.publish("Hello!", :routing_key => q.name)
16
-
17
- # demonstrates a blocking consumer that needs to cancel itself
18
- # in the message handler
19
- q.subscribe(:block => true) do |delivery_info, properties, payload|
20
- puts "Received #{payload}, cancelling"
21
- delivery_info.consumer.cancel
22
- end
23
-
24
- sleep 1.0
25
- conn.close
@@ -1,81 +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 "=> Subscribing for messages using explicit acknowledgements model"
10
- puts
11
-
12
- connection1 = Bunny.new
13
- connection1.start
14
-
15
- connection2 = Bunny.new
16
- connection2.start
17
-
18
- connection3 = Bunny.new
19
- connection3.start
20
-
21
- ch1 = connection1.create_channel
22
- ch1.prefetch(1)
23
-
24
- ch2 = connection2.create_channel
25
- ch2.prefetch(1)
26
-
27
- ch3 = connection3.create_channel
28
- ch3.prefetch(1)
29
-
30
- x = ch3.direct("amq.direct")
31
- q1 = ch1.queue("bunny.examples.acknowledgements.explicit", :auto_delete => false)
32
- q1.purge
33
-
34
- q1.bind(x).subscribe(:manual_ack => true, :block => false) do |delivery_info, properties, payload|
35
- # do some work
36
- sleep(0.2)
37
-
38
- # acknowledge some messages, they will be removed from the queue
39
- if rand > 0.5
40
- # FYI: there is a shortcut, Bunny::Channel.ack
41
- ch1.acknowledge(delivery_info.delivery_tag, false)
42
- puts "[consumer1] Got message ##{properties.headers['i']}, redelivered?: #{delivery_info.redelivered?}, ack-ed"
43
- else
44
- # some messages are not ack-ed and will remain in the queue for redelivery
45
- # when app #1 connection is closed (either properly or due to a crash)
46
- puts "[consumer1] Got message ##{properties.headers['i']}, SKIPPED"
47
- end
48
- end
49
-
50
- q2 = ch2.queue("bunny.examples.acknowledgements.explicit", :auto_delete => false)
51
- q2.bind(x).subscribe(:manual_ack => true, :block => false) do |delivery_info, properties, payload|
52
- # do some work
53
- sleep(0.2)
54
-
55
- ch2.acknowledge(delivery_info.delivery_tag, false)
56
- puts "[consumer2] Got message ##{properties.headers['i']}, redelivered?: #{delivery_info.redelivered?}, ack-ed"
57
- end
58
-
59
- t1 = Thread.new do
60
- i = 0
61
- loop do
62
- sleep 0.5
63
-
64
- x.publish("Message ##{i}", :headers => { :i => i })
65
- i += 1
66
- end
67
- end
68
- t1.abort_on_exception = true
69
-
70
- t2 = Thread.new do
71
- sleep 4.0
72
-
73
- connection1.close
74
- puts "----- Connection 1 is now closed (we pretend that it has crashed) -----"
75
- end
76
- t2.abort_on_exception = true
77
-
78
-
79
- sleep 7.0
80
- connection2.close
81
- connection3.close