[rabbitmq-discuss] Creating Queues and Exchanges on the Fly
Ben Hood
0x6e6562 at gmail.com
Thu Sep 4 21:04:23 BST 2008
Hey Preston,
On Thu, Sep 4, 2008 at 2:28 AM, Preston Marshall
<preston at synergy-solutions.biz> wrote:
> Now I have an interesting problem which probably requires and interesting
> solution :). I can successfully pass events through my different exchanges,
> i have a 'all' queue, along with national, regional, state, and stateregion.
> They all have different routing keys that can be used to send to them like
> for example one key is events.us.5.al.4, that in particular creates a queue
> named stateregion and binds to it with a key that listens for messages only
> for that state region, for that state, for that region, for that nation. Now
> what I need to do is setup a queue for events that are going on, as the
> queues I have now only pass new event notifications, not actualy
> communications for those events. Each new event has a UUID assoicated with
> it, so I was thinking that maybe I should create a new queue when a new
> event message comes in, based on the contents of the message. So I would
> have something like this:
>
> amq.queue('94a2b510-5c4c-012b-a451-001ff34e82f0').bind(amq.topic, :key =>
> "94a2b510-5c4c-012b-a451-001ff34e82f0.posts").subscribe
>
> where in reality I would have something like this, since new events will be
> created and destroyed on the fly, and base the new queue's key and name on a
> message recieved from a "parent" queue.:
>
> amq.queue(doc.elements['//eventuuid'].to_s).bind(amq.topic, :key =>
> "#{doc.elements['//eventuuid']}.posts").subscribe
>
> This queue allows for "posts" or basically pieces of information like SMS
> messages to be passed across the network, while referencing an event, which
> is the UUID.
>
> Is this the only way to this, or if not, the best? Wisdom tells me that if
> you are doing something that seems really complex and hard, there is
> probably a better and easier way that you haven't seen. I believe that my
> inexperience with AMQP and its nomenclature is causing me massive confusion
> and strife, which of course I'd love for you guys to help me out with.
Absolutely no offense intended, I've read through your mail twice and
I'm struggling to understand exactly what your problem is.
On face value, it looks like you should be using some kind of topic
exchange, which leads me to ask whether you've looked at the
specification for topic (taken from the spec):
"The routing pattern follows the same rules as the routing key with
the addition that * matches a single word, and # matches zero or more
words. Thus the routing pattern *.stock.# matches the routing keys
usd.stock and
eur.stock.db but not stock.nasdaq"
Of course you can create and delete exchanges, queues and bindings on the fly.
One thing you may want to consider when just creating stuff in an ad
hoc fashion is the associated cost.
Whilst the cost of any these operations is not much, it is definitely
non-zero, so at very high levels of usage, you might find that this is
something you want to economize on.
However, going back to your problem, if you could describe it with
less detail and make it clearer what your focus is, I'm sure that the
Rabbit community will be more than willing to help out.
HTH,
Ben
More information about the rabbitmq-discuss
mailing list