<div dir="ltr">Matthias,<br><br>Thank you. The round-robin and direct exchange were the missing parts.<br><br>Ben<br><br><div class="gmail_quote">On Mon, Oct 19, 2009 at 1:24 PM, Matthias Radestock <span dir="ltr"><<a href="mailto:matthias@lshift.net">matthias@lshift.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Ben,<br>
<div class="im"><br>
Ben Browitt wrote:<br>
> In my application I need to stream stock prices to users.<br>
> The 'last price' will be retrieved from a separate service when a<br>
> consumer connects which simplifies things.<br>
> Each user will subscribe to several stocks.<br>
> Users are web browsers connecting using long-polling.<br>
><br>
> Do I create one queue per consumer with several bindings, one for each<br>
> stock?<br>
> Prices in this case will be sent with a topic routing key.<br>
> Another option is to create one queue per stock. each consumer will be<br>
> subscribed to several queues.<br>
> Messages will be sent with a direct routing key.<br>
<br>
</div>In the latter case, each quote would only go to one consumer, which is<br>
probably not what you want. In an AMQP system, to get the same message<br>
delivered to N consumers you need (at least) N queues. Exchanges *copy*<br>
messages to queues, whereas queues *round-robin* message delivery to<br>
consumers.<br>
<br>
Your first setup should work fine, except there is no need to use a<br>
topic exchange. Just use a direct exchange, one queue per user and for<br>
each of the stock symbols a user is interested in create a binding<br>
between the user's queue and the direct exchange.<br>
<div class="im"><br>
> Users will connect using a browser with long-polling to the mochiweb plugin.<br>
> Each user will be presented at the server side as an erlang AMQP client.<br>
<br>
</div>Have you considered using the rabbitmq-jsonrpc-channel plugin? Even if<br>
you don't want to use it, it's worth taking a look at how it's<br>
implemented since that may well answer some of your questions regarding<br>
long-polling.<br>
<br>
<br>
Regards,<br>
<font color="#888888"><br>
Matthias.<br>
</font></blockquote></div><br></div>