bunny 2.15.0 → 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.
- checksums.yaml +4 -4
- data/README.md +30 -12
- data/lib/bunny/channel.rb +2 -2
- data/lib/bunny/reader_loop.rb +11 -11
- data/lib/bunny/session.rb +32 -9
- data/lib/bunny/transport.rb +12 -11
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_consume_spec.rb +14 -6
- data/spec/higher_level_api/integration/connection_spec.rb +26 -0
- data/spec/higher_level_api/integration/tls_connection_spec.rb +25 -32
- data/spec/issues/issue609_spec.rb +84 -0
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +1 -1
- data/spec/lower_level_api/integration/basic_consume_spec.rb +8 -8
- metadata +28 -87
- data/.github/ISSUE_TEMPLATE.md +0 -18
- data/.gitignore +0 -28
- data/.rspec +0 -1
- data/.travis.yml +0 -33
- data/.yardopts +0 -8
- data/CONTRIBUTING.md +0 -132
- data/ChangeLog.md +0 -2084
- data/Gemfile +0 -55
- data/LICENSE +0 -21
- data/Rakefile +0 -54
- data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
- data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
- data/benchmarks/channel_open.rb +0 -28
- data/benchmarks/mutex_and_monitor.rb +0 -42
- data/benchmarks/queue_declare.rb +0 -29
- data/benchmarks/queue_declare_and_bind.rb +0 -29
- data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
- data/benchmarks/synchronized_sorted_set.rb +0 -53
- data/benchmarks/write_vs_write_nonblock.rb +0 -49
- data/bunny.gemspec +0 -34
- data/docker/Dockerfile +0 -24
- data/docker/apt/preferences.d/erlang +0 -3
- data/docker/apt/sources.list.d/bintray.rabbitmq.list +0 -2
- data/docker/docker-entrypoint.sh +0 -26
- data/docker/rabbitmq.conf +0 -29
- data/docker-compose.yml +0 -28
- data/examples/connection/authentication_failure.rb +0 -16
- data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
- data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
- data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
- data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
- data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
- data/examples/connection/channel_level_exception.rb +0 -27
- data/examples/connection/disabled_automatic_recovery.rb +0 -34
- data/examples/connection/heartbeat.rb +0 -17
- data/examples/connection/manually_reconnecting_consumer.rb +0 -23
- data/examples/connection/manually_reconnecting_publisher.rb +0 -28
- data/examples/connection/unknown_host.rb +0 -16
- data/examples/consumers/high_and_low_priority.rb +0 -50
- data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
- data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
- data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
- data/examples/guides/exchanges/mandatory_messages.rb +0 -30
- data/examples/guides/extensions/alternate_exchange.rb +0 -30
- data/examples/guides/extensions/basic_nack.rb +0 -33
- data/examples/guides/extensions/connection_blocked.rb +0 -35
- data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
- data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
- data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
- data/examples/guides/extensions/per_message_ttl.rb +0 -36
- data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
- data/examples/guides/extensions/publisher_confirms.rb +0 -28
- data/examples/guides/extensions/queue_lease.rb +0 -26
- data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
- data/examples/guides/getting_started/blabbr.rb +0 -27
- data/examples/guides/getting_started/hello_world.rb +0 -22
- data/examples/guides/getting_started/weathr.rb +0 -49
- data/examples/guides/queues/one_off_consumer.rb +0 -25
- data/examples/guides/queues/redeliveries.rb +0 -81
- data/profiling/basic_publish/with_4K_messages.rb +0 -33
- data/repl +0 -3
- data/spec/tls/ca_certificate.pem +0 -29
- data/spec/tls/ca_key.pem +0 -52
- data/spec/tls/client_certificate.pem +0 -29
- data/spec/tls/client_key.pem +0 -51
- data/spec/tls/generate-server-cert.sh +0 -8
- data/spec/tls/server-openssl.cnf +0 -10
- data/spec/tls/server.csr +0 -16
- data/spec/tls/server_certificate.pem +0 -29
- data/spec/tls/server_key.pem +0 -51
@@ -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
data/spec/tls/ca_certificate.pem
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIFAjCCAuqgAwIBAgIJAOh5ofB2iC1IMA0GCSqGSIb3DQEBCwUAMDExIDAeBgNV
|
3
|
-
BAMMF1RMU0dlblNlbGZTaWduZWR0Um9vdENBMQ0wCwYDVQQHDAQkJCQkMB4XDTE3
|
4
|
-
MDcxMjE3MDUyNFoXDTI3MDcxMDE3MDUyNFowMTEgMB4GA1UEAwwXVExTR2VuU2Vs
|
5
|
-
ZlNpZ25lZHRSb290Q0ExDT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