I read your second mail already but I wanted to comment on some of the stuff you said in this just so when you sit down with the AMPQ guys we get a clear picture of capabilities (I would like to be in on that discussion BTW, given my experience dealing with message buses).
----- "Luke Macken" <lmacken(a)redhat.com> wrote:
<snip/>
>
> The reason for using AMQP is because of the way the browser consumes
> messages from the queues. Right now, widgets can consume messages
> from
> an AMQP queue over STOMP. However, they have no other capabilities,
> such as creating AMQP queues or exchanges, which means that we cannot
> properly do AMQP multicasting.
I'm not quite sure I understand the multicast bit but in no way do we want to allow a client to create queues from JavaScript. We want them to consume from already existing queues. If they want to request something they go through a connector. AMQP is simply there for push publishing (e.g. signals that an event has happened).
> Right now when a client consumes a
> message from a given queue -- no one else can consume that message
> from
> that particular queue. This is a huge roadblock, but there are a
> couple
> of ways around it...
That seems off. Are you sure you are using the correct portion of the spec? Any message bus should be able to distribute a message to anyone who can subscribe to it. Imagine a world where a stock gets updated and only one person can see that message. I think I see the issue looking at some client code. There are Brokers and Queues. Brokers are the bus, anytime they see a message they look to see if any queue is subscribed to that message and put it in that queue. Brokers are inherently multi-casting. More comments bellow.
> The ideal solution, from my limited understanding of AMQP, is to have
> each client create their own personal (auto-deleting) queue, and bind
> it
> to a `fanout` exchange. This will allow for multicast AMQP messages.
I don't think a fanout is you think it is. It is simply an exchange that ignore routing options when publishing to a queue. e.g. every queue in the exchange gets the message whether or not they requested to listen to it.
What we want is for moksha.EventService (or something to that effect) acting as an exchange with one queue per route it is listening to. In effect this would be a queue on the Fedora exchange. The event service would take requests to listen for a topic from live widgets and store their orbitted channel id in a table that associates it with a list of topics (well actually it would be a topics table with a list of orbitted channels). If the topic comes up you send the contents to all the channels which are subscribed. If the channel gets close you take it out of the table. Alternately, you create a queue for each orbitted connection and add routing criteria for listen request from the client. When a message comes into a queue, it gets shipped off to the connection associate with it. The client should only ever care about being able to subscribe to a topic and then have a callback get triggered with the message's payload as a parameter. The client code would look something like this:
es = moksha.get_event_service() // perhaps we allow multiple event services with noargs = get default
es.subscribe('koji.build.status_changed', status_changed_cb)
es.subscribe('koji.build.new_build', new_build_cb)
es.subscribe('bodhi.*', bodhi_events_cb) //get all bodhi events
def status_changed_cb(json) { alert('koji sent us a status change for build ' + json.build.build_id.toString()); }
def new_build_cb(json) { alert('A new build has just started for package ' + json.build.nvr); }
def bodhi_events_cb(json){ alert('Bodhi just sent us the ' + json.topic + ' event'); }
Our AMQP setup in Fedora would look like:
koji, bodhi, fas, pkgdb, etc AMQP producer clients.
_____________________________
| Fedora AMQP Exchange |
| |
| | |Fedora Community |
| | |serverside queue |
|____| |______________________|
|
|
\|/
____| |______________________
| | | Moksha AMQP |
| | | Client |
| | | FC Local Queue |
| | |
| \|/ |
| lookup_conn_for_topic() |
|_____|_______________________|
/ \
/ \
|/ \
_________ |
|live | |
|widget | |
|topic | |
|consumer | |
|#1 | |
|_________| |
___\|/___
|live |
|widget |
|topic |
|consumer |
|#2 |
|_________|
--
John (J5) Palmieri
Software Engineer
Red Hat, Inc.