Sha256: 88e4cd314a30a31f969edbc7a18b7545e13fa6a24f9967cb906f2a6c5685d124

Contents?: true

Size: 540 Bytes

Versions: 15

Compression:

Stored size: 540 Bytes

Contents

# encoding: utf - 8

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

require "amqp"

# Imagine the command is something
# CPU - intensive like image processing.
command = "sleep 0.1"

AMQP.start(port: 1112) do
  amq = AMQP::Channel.new
  exchange = amq.direct("tasks")
  queue = amq.queue("tasks")

  # And this is user - input simulation,
  # which can be a user uploading an image.
  EM.add_periodic_timer(1) do
    puts "~ publishing #        {command}"
    exchange.publish(command, :routing_key => "tasks")
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
amqp-0.8.0.rc13 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc12 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc11 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc10 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc9 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc8 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc7 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc6 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc5 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc4 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc3 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc2 examples/real-world/task-queue/producer.rb
amqp-0.8.0.rc1 examples/real-world/task-queue/producer.rb
amqp-0.8.0.pre.beta1 examples/real-world/task-queue/producer.rb
amqp-0.8.0.beta1 examples/real-world/task-queue/producer.rb