<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CMRAMAM%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:"Times New Roman";}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:"Courier New";
        mso-fareast-font-family:"Times New Roman";}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;
        mso-header-margin:.5in;
        mso-footer-margin:.5in;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style><pre>&gt;You need to declare an exchange (of type direct, fanout or topic)<span style="">� </span></pre><pre>&gt;which acts as the mailbox for sending the message. </pre><pre>�</pre><pre>Thank you for taking time to answer my questions. </pre>
<pre>�</pre><pre>&gt;Once you have parsed the message from socket server and determined it &gt;should go to rabbit, you publish the message to it. </pre><pre>�</pre><pre>I don�t know Ruby. I wrote a PHP program that parse the message from socket server and pass the message to RabbitMQ server. When <br>
the message comes back from RabbitMQ, I format it and send to socket server that forwards the message to iPhone. </pre><pre>�</pre><pre>The catch here is the performance. iPhone needs to query for the message in the queue every few seconds. Let us assume <br>
that User A and User B chats thru iPhone application. User A sends the message to RabbitMQ. </pre><pre>�</pre><pre>User A -&gt; Socket Server -&gt; RabbitMQ Server</pre><pre>�</pre><pre>RabbitMQ has no way of sending the notification to User B that some message is waiting for him. </pre>
<pre>�</pre><pre>User B needs to check the RabbitMQ server every 5 seconds to see if there is any message in his queue. </pre><pre>�</pre><pre>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>�</pre><pre>Is there a better way to do it? Thanks.</pre><pre>�</pre><br><br><div class="gmail_quote">On Tue, Sep 15, 2009 at 7:27 PM, Chuck Remes <span dir="ltr">&lt;<a href="mailto:cremes.devlist@mac.com">cremes.devlist@mac.com</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;"><div class="im"><br>
On Sep 15, 2009, at 7:19 PM, Alex Gentle wrote:<br>
<br>
&gt; iPhone app -&gt; socket server -&gt; RabbitMQ server<br>
<br>
</div>Great, this is very helpful.<br>
<div class="im"><br>
&gt; iPhone app has some social networking features in addition to the<br>
&gt; chat component. Think of it like mini-facebook inside iPhone. When a<br>
&gt; user types a message inside chat window of iPhone app, the message<br>
&gt; travels to Socket server which directs the message depending on what<br>
&gt; is on the message header. If the message header says &quot;this message<br>
&gt; is for RabbitMQ&quot;, socket server will route to RabbitMQ. When a<br>
&gt; message comes from RabbitMQ to socket server, it should have message<br>
&gt; header that says &quot;Route this to xxxxxx user&quot;. Then, socket server<br>
&gt; will route the message to appropriate user(s).<br>
&gt;<br>
&gt; It all looks good, but it doesn&#39;t work. Because I don&#39;t know how to<br>
&gt; make a call to RabbitMQ using the message from socket server and how<br>
&gt; to pass the message from RabbitMQ to socket server in binary format.<br>
<br>
</div>Ah, this is good.<br>
<br>
You need to declare an exchange (of type direct, fanout or topic)<br>
which acts as the mailbox for sending the message. Once you have<br>
parsed the message from socket server and determined it should go to<br>
rabbit, you publish the message to it. Here&#39;s some ruby code<br>
(commented).<br>
<br>
def publish_message_to_rabbit(message)<br>
 � # declare the exchange<br>
 � exchange = MQ.direct &#39;mailbox&#39;<br>
<br>
 � # send the message<br>
 � exchange.publish(message, :key =&gt; &#39;some.routing.key&#39;)<br>
end<br>
<br>
Next, you need to have a client somewhere that is listening for<br>
messages. You need to allocate a queue to receive the message and<br>
subscribe to the routing key. Again, some ruby code.<br>
<br>
def listen_for_rabbit_messages<br>
 � # redeclare the exchange; idempotent operation<br>
 � exchange = MQ.direct &#39;mailbox&#39;<br>
<br>
 � # declare a queue to receive the messages<br>
 � queue = MQ.queue &#39;mailslot&#39;<br>
<br>
 � # bind the queue to the exchange and match incoming messages against<br>
 � # the specified routing key<br>
 � queue.bind(exchange, :key =&gt; &#39;some.routing.key&#39;).subscribe do |<br>
message|<br>
 � � # this block is called each time a message is received<br>
 � � # do your message processing here<br>
 � end<br>
end<br>
<br>
Does this help? I highly recommend you take a look through the sample<br>
code and come back with specific questions.<br>
<div><div></div><div class="h5"><br>
cr<br>
<br>
<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>
</div></div></blockquote></div><br>