Sha256: f85b71ace1d82422626dd04d0d619c8d391352e6ab0499f567b3bcf3d381b542

Contents?: true

Size: 1.07 KB

Versions: 53

Compression:

Stored size: 1.07 KB

Contents

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

require "bundler"
Bundler.setup

$:.unshift(File.expand_path("../../../lib", __FILE__))

require "amqp"

EventMachine.run do
  AMQP.connect do |connection|
    channel1  = AMQP::Channel.new(connection)
    channel2  = AMQP::Channel.new(connection)
    exchange = channel1.default_exchange

    q1 = channel1.queue("amqpgem.examples.queues.shared", :auto_delete => true)
    q1.subscribe do |payload|
      puts "Queue #{q1.name} on channel 1 received #{payload}"
    end

    q2 = channel2.queue("amqpgem.examples.queues.shared", :auto_delete => true)
    q2.subscribe do |payload|
      puts "Queue #{q2.name} on channel 2 received #{payload}"
    end

    # Publish some test data in a bit, after all queues are declared & bound
    EventMachine.add_timer(1.2) do
      5.times { |i| exchange.publish("Hello #{i}, direct exchanges world!", :routing_key => "amqpgem.examples.queues.shared") }
    end


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

    Signal.trap "TERM", show_stopper
    EM.add_timer(3, show_stopper)
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

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