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-1.3.1 examples/guides/extensions/per_message_ttl.rb
bunny-1.3.0 examples/guides/extensions/per_message_ttl.rb
bunny-1.2.2 examples/guides/extensions/per_message_ttl.rb
bunny-1.2.1 examples/guides/extensions/per_message_ttl.rb
bunny-1.2.0 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.9 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.8 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.7 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.6 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.5 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.4 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.3 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.2 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.1 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.0 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.0.rc1 examples/guides/extensions/per_message_ttl.rb
bunny-1.0.7 examples/guides/extensions/per_message_ttl.rb
bunny-1.0.6 examples/guides/extensions/per_message_ttl.rb
bunny-1.0.5 examples/guides/extensions/per_message_ttl.rb
bunny-1.1.0.pre2 examples/guides/extensions/per_message_ttl.rb