bunny 2.14.2 → 2.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -39
  3. data/lib/bunny/channel.rb +89 -13
  4. data/lib/bunny/consumer.rb +2 -2
  5. data/lib/bunny/consumer_work_pool.rb +1 -1
  6. data/lib/bunny/cruby/socket.rb +3 -0
  7. data/lib/bunny/delivery_info.rb +1 -1
  8. data/lib/bunny/queue.rb +36 -5
  9. data/lib/bunny/reader_loop.rb +21 -13
  10. data/lib/bunny/session.rb +83 -25
  11. data/lib/bunny/transport.rb +49 -12
  12. data/lib/bunny/version.rb +1 -1
  13. data/lib/bunny.rb +45 -4
  14. metadata +37 -235
  15. data/.github/ISSUE_TEMPLATE.md +0 -18
  16. data/.gitignore +0 -28
  17. data/.rspec +0 -1
  18. data/.travis.yml +0 -31
  19. data/.yardopts +0 -8
  20. data/CONTRIBUTING.md +0 -132
  21. data/ChangeLog.md +0 -2072
  22. data/Gemfile +0 -55
  23. data/LICENSE +0 -21
  24. data/Rakefile +0 -54
  25. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  26. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  27. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  28. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  29. data/benchmarks/channel_open.rb +0 -28
  30. data/benchmarks/mutex_and_monitor.rb +0 -42
  31. data/benchmarks/queue_declare.rb +0 -29
  32. data/benchmarks/queue_declare_and_bind.rb +0 -29
  33. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  34. data/benchmarks/synchronized_sorted_set.rb +0 -53
  35. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  36. data/bunny.gemspec +0 -34
  37. data/docker/Dockerfile +0 -20
  38. data/docker/apt/preferences.d/erlang +0 -3
  39. data/docker/apt/sources.list.d/bintray.rabbitmq.list +0 -2
  40. data/docker/docker-entrypoint.sh +0 -26
  41. data/docker/rabbitmq.conf +0 -29
  42. data/docker-compose.yml +0 -28
  43. data/examples/connection/authentication_failure.rb +0 -16
  44. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  45. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  46. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  47. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  48. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  49. data/examples/connection/channel_level_exception.rb +0 -27
  50. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  51. data/examples/connection/heartbeat.rb +0 -17
  52. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  53. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  54. data/examples/connection/unknown_host.rb +0 -16
  55. data/examples/consumers/high_and_low_priority.rb +0 -50
  56. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  57. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  58. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  59. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  60. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  61. data/examples/guides/extensions/basic_nack.rb +0 -33
  62. data/examples/guides/extensions/connection_blocked.rb +0 -35
  63. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  64. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  65. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  66. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  67. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  68. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  69. data/examples/guides/extensions/queue_lease.rb +0 -26
  70. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  71. data/examples/guides/getting_started/blabbr.rb +0 -27
  72. data/examples/guides/getting_started/hello_world.rb +0 -22
  73. data/examples/guides/getting_started/weathr.rb +0 -49
  74. data/examples/guides/queues/one_off_consumer.rb +0 -25
  75. data/examples/guides/queues/redeliveries.rb +0 -81
  76. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  77. data/repl +0 -3
  78. data/spec/config/enabled_plugins +0 -1
  79. data/spec/config/rabbitmq.conf +0 -13
  80. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
  81. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
  82. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -349
  83. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  84. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -80
  85. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
  86. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
  87. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
  88. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
  89. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  90. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -66
  91. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  92. data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -483
  93. data/spec/higher_level_api/integration/connection_spec.rb +0 -563
  94. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
  95. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  96. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
  97. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  98. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
  99. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  100. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  101. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  102. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -49
  103. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  104. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  105. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -191
  106. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
  107. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  108. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -285
  109. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  110. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  111. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  112. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  113. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  114. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -250
  115. data/spec/higher_level_api/integration/toxiproxy_spec.rb +0 -76
  116. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  117. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  118. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  119. data/spec/issues/issue100_spec.rb +0 -42
  120. data/spec/issues/issue141_spec.rb +0 -43
  121. data/spec/issues/issue202_spec.rb +0 -15
  122. data/spec/issues/issue224_spec.rb +0 -40
  123. data/spec/issues/issue465_spec.rb +0 -32
  124. data/spec/issues/issue549_spec.rb +0 -30
  125. data/spec/issues/issue78_spec.rb +0 -72
  126. data/spec/issues/issue83_spec.rb +0 -30
  127. data/spec/issues/issue97_attachment.json +0 -1
  128. data/spec/issues/issue97_spec.rb +0 -175
  129. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
  130. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
  131. data/spec/spec_helper.rb +0 -47
  132. data/spec/stress/channel_close_stress_spec.rb +0 -64
  133. data/spec/stress/channel_open_stress_spec.rb +0 -84
  134. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  135. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
  136. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
  137. data/spec/stress/connection_open_close_spec.rb +0 -52
  138. data/spec/stress/merry_go_round_spec.rb +0 -105
  139. data/spec/tls/ca_certificate.pem +0 -29
  140. data/spec/tls/ca_key.pem +0 -52
  141. data/spec/tls/client_certificate.pem +0 -29
  142. data/spec/tls/client_key.pem +0 -51
  143. data/spec/tls/generate-server-cert.sh +0 -8
  144. data/spec/tls/server-openssl.cnf +0 -10
  145. data/spec/tls/server.csr +0 -16
  146. data/spec/tls/server_certificate.pem +0 -29
  147. data/spec/tls/server_key.pem +0 -51
  148. data/spec/toxiproxy_helper.rb +0 -28
  149. data/spec/unit/bunny_spec.rb +0 -15
  150. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  151. data/spec/unit/concurrent/condition_spec.rb +0 -82
  152. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  153. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  154. data/spec/unit/exchange_recovery_spec.rb +0 -39
  155. data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -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
@@ -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
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require "rubygems"
5
- require "bunny"
6
- require "ruby-prof"
7
-
8
- conn = Bunny.new
9
- conn.start
10
-
11
- puts
12
- puts "-" * 80
13
- puts "Benchmarking on #{RUBY_DESCRIPTION}"
14
-
15
- n = 50_000
16
- ch = conn.create_channel
17
- x = ch.default_exchange
18
- s = "z" * 4096
19
-
20
- # warm up the JIT, etc
21
- puts "Doing a warmup run..."
22
- 16000.times { x.publish(s, :routing_key => "anything") }
23
-
24
- # give OS, the server and so on some time to catch
25
- # up
26
- sleep 2.0
27
-
28
- result = RubyProf.profile do
29
- n.times { x.publish(s, :routing_key => "anything") }
30
- end
31
-
32
- printer = RubyProf::FlatPrinter.new(result)
33
- printer.print(STDOUT, {})
data/repl DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/sh
2
-
3
- bundle exec ripl -Ilib -r'bunny' -r'ripl/multi_line' -r'ripl/irb'
@@ -1 +0,0 @@
1
- [rabbitmq_management, rabbitmq_consistent_hash_exchange].
@@ -1,13 +0,0 @@
1
- listeners.tcp.1 = 0.0.0.0:5672
2
-
3
- listeners.ssl.default = 5671
4
-
5
- # mounted by docker-compose
6
- ssl_options.cacertfile = /spec/tls/ca_certificate.pem
7
- ssl_options.certfile = /spec/tls/server_certificate.pem
8
- ssl_options.keyfile = /spec/tls/server_key.pem
9
-
10
- ssl_options.verify = verify_none
11
- ssl_options.fail_if_no_peer_cert = false
12
-
13
- loopback_users = none