Sha256: 5273855d1063948ac5154a64556ee6403372d2532e6a88f8374d0fb1333c05d9

Contents?: true

Size: 1.23 KB

Versions: 22

Compression:

Stored size: 1.23 KB

Contents

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

require "bundler"
Bundler.setup

$:.unshift(File.expand_path("../../../../lib", __FILE__))
require 'amqp'
require "amqp/extensions/rabbitmq"

EventMachine.run do
  connection = AMQP.connect(:host => '127.0.0.1')
  puts "Connecting to AMQP broker. Running #{AMQP::VERSION} version of the gem..."

  AMQP::Channel.new(connection) do |channel|
    puts "Channel #{channel.id} is now open"

    channel.confirm_select
    channel.on_error { |ch, channel_close| puts "Oops! a channel-level exception: #{channel_close.reply_text}" }
    channel.on_ack   { |basic_ack| puts "Received basic_ack: multiple = #{basic_ack.multiple}, delivery_tag = #{basic_ack.delivery_tag}" }

    x = channel.fanout("amq.fanout")
    channel.queue("", :auto_delete => true) do |q|
      q.bind(x).subscribe(:ack => true) do |header, payload|
        puts "Received #{payload}"
      end
    end

    EventMachine.add_timer(0.5) do
      10.times do |i|
        puts "Publishing message ##{i + 1}"
        x.publish("Message ##{i + 1}")
      end
    end
  end

  show_stopper = Proc.new {
    connection.close { EventMachine.stop }
  }

  EM.add_timer(6, show_stopper)
  Signal.trap('INT',  show_stopper)
  Signal.trap('TERM', show_stopper)
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
amqp-0.9.10 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.9 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.8 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.0.0.pre2 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.7 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.6 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.0.0.pre1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.5 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.4 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.3 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.2 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.0.pre3 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.0.pre2 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.9.0.pre1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.8.4 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.8.3 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.8.2 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-0.8.1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb