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-0.9.0.pre8 examples/guides/extensions/per_message_ttl.rb
bunny-0.9.0.pre7 examples/guides/extensions/per_message_ttl.rb
bunny-0.9.0.pre6 examples/guides/extensions/per_message_ttl.rb
bunny-0.9.0.pre5 examples/guides/extensions/per_message_ttl.rb