[rabbitmq-discuss] Streaming stock prices to long-polling clients

Ben Browitt ben.browitt at gmail.com
Thu Oct 15 10:51:33 BST 2009


In my application I need to stream stock prices to users.
The 'last price' will be retrieved from a separate service when a consumer
connects which simplifies things.
Each user will subscribe to several stocks.
Users are web browsers connecting using long-polling.

Do I create one queue per consumer with several bindings, one for each
Prices in this case will be sent with a topic routing key.
Another option is to create one queue per stock. each consumer will be
subscribed to several queues.
Messages will be sent with a direct routing key.

Users will connect using a browser with long-polling to the mochiweb plugin.
Each user will be presented at the server side as an erlang AMQP client.
When using long-polling it is possible that the server sent responses to
both connections and have to wait for the user to send a new request.
How do I handle this scenario? Does the erlang client store the messages in
its state?
Every time the erlang client gets a new long-polling request it checks for
messages in the state,
if there are messages it sends them immediately and if there aren't it
keep-alive the request.
Another option is that the erlang client will acknowledge messages only if
it can pass it to the web client.
What will happen in this case? Will the queue keep sending new messages or
will it wait for the erlang client o 'initialize' the channel?
Are there a suspend and resume features?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20091015/ab24e5d3/attachment.htm 

More information about the rabbitmq-discuss mailing list