<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">&lt;<a href="mailto:matthias@lshift.net">matthias@lshift.net</a>&gt;</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>
&gt; In my application I need to stream stock prices to users.<br>
&gt; The &#39;last price&#39; will be retrieved from a separate service when a<br>
&gt; consumer connects which simplifies things.<br>
&gt; Each user will subscribe to several stocks.<br>
&gt; Users are web browsers connecting using long-polling.<br>
&gt;<br>
&gt; Do I create one queue per consumer with several bindings, one for each<br>
&gt; stock?<br>
&gt; Prices in this case will be sent with a topic routing key.<br>
&gt; Another option is to create one queue per stock. each consumer will be<br>
&gt; subscribed to several queues.<br>
&gt; 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&#39;s queue and the direct exchange.<br>
<div class="im"><br>
&gt; Users will connect using a browser with long-polling to the mochiweb plugin.<br>
&gt; 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&#39;t want to use it, it&#39;s worth taking a look at how it&#39;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>