Sha256: 7b53ebedabbfcf937705657f3d47d345356b8de74d13d58417c28320ac6fef80

Contents?: true

Size: 607 Bytes

Versions: 124

Compression:

Stored size: 607 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

require "rubygems"
require "bunny"

puts "=> Demonstrating per-message TTL"
puts

conn = Bunny.new
conn.start

ch   = conn.create_channel
x    = ch.fanout("amq.fanout")
q    = ch.queue("", :exclusive => true).bind(x)

10.times do |i|
  x.publish("Message #{i}", :expiration => 1000)
end

sleep 0.7
_, _, content1 = q.pop
puts "Fetched #{content1.inspect} after 0.7 second"

sleep 0.8
_, _, content2 = q.pop
msg = if content2
        content2.inspect
      else
        "nothing"
      end
puts "Fetched #{msg} after 1.5 second"

sleep 0.7
puts "Closing..."
conn.close

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
bunny-2.17.0 examples/guides/extensions/per_message_ttl.rb
bunny-2.16.1 examples/guides/extensions/per_message_ttl.rb
bunny-2.15.0 examples/guides/extensions/per_message_ttl.rb
bunny-2.14.4 examples/guides/extensions/per_message_ttl.rb
bunny-2.14.3 examples/guides/extensions/per_message_ttl.rb
bunny-2.14.2 examples/guides/extensions/per_message_ttl.rb
bunny-2.14.1 examples/guides/extensions/per_message_ttl.rb
bunny-2.13.0 examples/guides/extensions/per_message_ttl.rb
bunny-2.12.1 examples/guides/extensions/per_message_ttl.rb
bunny-2.12.0 examples/guides/extensions/per_message_ttl.rb
bunny-2.12.0.rc1 examples/guides/extensions/per_message_ttl.rb
bunny-2.11.0 examples/guides/extensions/per_message_ttl.rb
bunny-2.11.0.pre1 examples/guides/extensions/per_message_ttl.rb
bunny-2.10.0 examples/guides/extensions/per_message_ttl.rb
bunny-2.9.2 examples/guides/extensions/per_message_ttl.rb
bunny-2.9.1 examples/guides/extensions/per_message_ttl.rb
bunny-2.6.7 examples/guides/extensions/per_message_ttl.rb
bunny-2.7.4 examples/guides/extensions/per_message_ttl.rb
bunny-2.8.1 examples/guides/extensions/per_message_ttl.rb
bunny-2.9.0 examples/guides/extensions/per_message_ttl.rb