jgeiger
unread,Nov 19, 2009, 11:22:10 AM11/19/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AMQP
I've set up a master/worker system using rabbit and amqp, and I'm
trying to determine if what I'm doing is the best way to be doing it.
My system consists of 4 parts databaser, scheduler, node and worker.
The scheduler finds jobs and distributes them to the workers via an
individual queue. The node listens to it's queue and launches workers
as requested by the scheduler, the databaser listens to it's queue,
and saves info into the DB. The worker listens to it's own queue and
sends status updates to the scheduler queue. I originally set up the
queues as:
(scheduler-queue, databaser-queue, node-queue)
and then 1 queue per worker
(worker-1-queue, worker-2-queue, etc.)
This is an issue since I was creating a lot of queues for the workers,
and while they were set to auto delete, it just didn't seem right (and
a few of them became orphaned)
I made a new change to replace the multiple worker queues with a topic
and key, so all the worker daemons listen to the same created queue,
but only pull messages off based on their key.
amq = ::MQ.new
amq.queue("worker").bind(@amq.topic('job'), :key =>
worker_key).subscribe { |msg| ... }
The part that is confusing me, is that in the scheduler when sending a
message to a worker I'm posting a message to the system, but marking
it with a topic and key, and not dropping it on a specific queue.
amq = ::MQ.new
amq.topic('job').publish(msg, :key => worker_key)
but, when sending a message to the node-queue, I'm sending it directly
to the queue.
amq.queue('node', :durable => true).publish(msg, :persistent => true)
I'm wondering if I would be better off just sending all messages to
topics and keys, even if I only have one thing listening to that
topic
amq.topic('node').publish(msg, :key => 'node')
amq.topic('databaser').publish(msg, :key => 'databaser')
or should I continue with publishing directly to the queue? Or is
there a better way altogether?
Thanks.