Sha256: e273e121269e51056e6543b7607383ba631e044afaa95d1afa9a898c4417f5a0

Contents?: true

Size: 1.23 KB

Versions: 30

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 RabbitMQ. 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

30 entries across 30 versions & 1 rubygems

Version Path
amqp-1.8.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.7.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.6.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.5.3 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.5.2 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.5.1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.5.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.4.2 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.4.1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.4.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.3.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.2.1 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.2.0 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.1.8 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.1.7 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.1.6 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.1.5 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.1.4 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.1.3 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb
amqp-1.0.4 examples/extensions/rabbitmq/publisher_confirmations_with_transient_messages.rb