Hi Chuck, <br><br><div>>I think we are getting ahead of ourselves. Your original post
indicated that your code did not work but now you are worried about
performance. Let's get your code working first and then you can worry
>about optimizing it later.</div><div><br></div><div>>Can you successfully publish your messages yet? If so, can you pop them off of the queue to read them?</div><div><br>Yes. The code is working. I can publish and retrieve the messages from the queue. It works well.<br>
<br><div>>Polling is usually a bad idea particularly since it requires a lot
of unnecessary messaging. Most AMQP libraries I have seen allow for two
ways to fetch messages. One way is to "get" them from the >queue which
is a synchronous operation. The second way is to "subscribe" to a queue
and have it asynchronously push messages to the subscriber. You want to
investigate this second methodology >for your application. Async
operations result in slightly more complex code but they will let you
scale better than polling/synchronous operations.</div><div><br>This is news to me. I thought that client has to run the call to fetch the message that is in the client's queue, even if the client subscribes to it. Could you please explain pushing messages to the subscriber. If I have socket server in the middle, will it block the pushed messages? I want to trigger some kind of signal from rabbitmq to the client when a message is waiting for the client so that client doesn't need to poll every few seconds. <br>
<br>Thank you.<br></div><br></div><br><div class="gmail_quote">On Fri, Sep 18, 2009 at 5:27 AM, Chuck Remes <span dir="ltr"><<a href="mailto:cremes.devlist@mac.com">cremes.devlist@mac.com</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;">
<div style="word-wrap: break-word;"><br><div><div class="im"><div>On Sep 17, 2009, at 7:40 PM, Alex Gentle wrote:</div><br><blockquote type="cite"><span style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">>Once you have parsed the message from socket server and determined it >should go to rabbit, you publish the message to it. </pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';"> </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">I don’t know Ruby. I wrote a PHP program that parse the message from socket server and pass the message to RabbitMQ server.</pre>
</div></span></blockquote><div><br></div><div><br></div></div><div>I wrote the examples in ruby since the code is very compact. You can perform the same operations in any language that has an AMQP library.</div><div class="im">
<div><br></div><br><blockquote type="cite"><span style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">The catch here is the performance. iPhone needs to query for the message in the queue every few seconds. </pre></div></span></blockquote>
<div><br></div><div><br></div></div><div>I think we are getting ahead of ourselves. Your original post indicated that your code did not work but now you are worried about performance. Let's get your code working first and then you can worry about optimizing it later.</div>
<div><br></div><div>Can you successfully publish your messages yet? If so, can you pop them off of the queue to read them?</div><div class="im"><div><br></div><br><blockquote type="cite"><span style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">Let us assume </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">that User A and User B chats thru iPhone application. User A sends the message to RabbitMQ. </pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';"> </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">User A -> Socket Server -> RabbitMQ Server</pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';"> </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">RabbitMQ has no way of sending the notification to User B that some message is waiting for him. </pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';"> </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">User B needs to check the RabbitMQ server every 5 seconds to see if there is any message in his queue. </pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';"> </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">Imagine there are 10,000 users like user A and B. All of them will be sending the message thru socket server to RabbitMQ server. Socket <br>
server can handle all the traffic. It’s a piece of cake for RabbitMQ to handle the traffic. But, the poor PHP program in the middle <br>(between socket server and RabbitMQ) can’t handle all the incoming and outgoing requests with ease. It’s going to slow down the process. <br>
Users will see substantial delay in sending and receiving messages. </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';"> </pre><pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: 'Courier New';">
Is there a better way to do it? Thanks.</pre></div></span></blockquote><br></div></div><div>Polling is usually a bad idea particularly since it requires a lot of unnecessary messaging. Most AMQP libraries I have seen allow for two ways to fetch messages. One way is to "get" them from the queue which is a synchronous operation. The second way is to "subscribe" to a queue and have it asynchronously push messages to the subscriber. You want to investigate this second methodology for your application. Async operations result in slightly more complex code but they will let you scale better than polling/synchronous operations.</div>
<div><br></div><font color="#888888"><div>cr</div><div><br></div></font></div><br>_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br></blockquote></div><br>