Sha256: 71821f20b6f632b7acc5f280879d573165690d3115432e1872321b2c2b5b0a87
Contents?: true
Size: 812 Bytes
Versions: 12
Compression:
Stored size: 812 Bytes
Contents
#!/usr/bin/env ruby # encoding: utf-8 require "bundler" Bundler.setup $:.unshift(File.expand_path("../../../lib", __FILE__)) require 'bunny' conn = Bunny.new(:heartbeat_timeout => 8) conn.start ch = conn.create_channel x = ch.topic("bunny.examples.recovery.topic", :durable => false) q = ch.queue("bunny.examples.recovery.client_named_queue2", :durable => true) q.purge q.bind(x, :routing_key => "abc").bind(x, :routing_key => "def") loop do sleep 8 body = rand.to_s begin x.publish(body, :routing_key => ["abc", "def"].sample) puts "Published #{body}" # happens when a message is published before the connection # is recovered rescue Exception => e end sleep 1.5 _, _, payload = q.pop if payload puts "Consumed #{payload}" else puts "Consumed nothing" end end
Version data entries
12 entries across 12 versions & 1 rubygems