<div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">mysurf mail</b> <span dir="ltr">&lt;<a href="mailto:stammailbox@gmail.com">stammailbox@gmail.com</a>&gt;</span><br>
Date: Wed, Jul 13, 2011 at 4:27 PM<br>Subject: Re: [rabbitmq-discuss] a few json rpc questions<br>To: Emile Joubert &lt;<a href="mailto:emile@rabbitmq.com">emile@rabbitmq.com</a>&gt;<br><br><br><div dir="ltr"><div><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr">
<font face="Arial"></font></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><font face="Arial"><span style="font-family:Arial;color:black">Hi Emile, </span></font></p><font face="Arial">

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">Thanks for the assistance.</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">Though I have read the
tutorial in your site, it looks like I did not fully understand the rpc for
multiple clients&#39; mechanism. </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">What I want is that the rpc
server will serve all rpc clients. </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">I don&#39;t know how many
clients I will have in advance.</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">I have a lot and some will
run from the same folder with the same configurations (more that one instance)</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">I have put a routing key in
the server and all the clients (same one) and I thought it would make the server handle all the
requests. </span></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">1. Is there any way to use the rpc like that for multiple clients?</span></p></font><span style="font-family:Arial">2. Would I need to give each
one a different routing key? </span><font face="Arial"><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">3. Would I need to use different server threads for each client? </span></p>


<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"><br></span></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">Thanks. </span></p>


<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"><br></span></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">I will add my client /
server code. </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">I would appreciate it very
much if you elaborate your answer </span></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">Thank you.</span></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr">
<span style="font-family:Arial;color:black"><br></span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">My server code ( try catch keywords were removed for
clarity)</span></p><p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br></span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>    </span>public
void startListenToClients() {</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>ConnectionFactory connFactory = new ConnectionFactory();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>connFactory.setHost(props.getProperty(&quot;Host&quot;));</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>connFactory.setPort(Integer.parseInt(props.getProperty(&quot;Port&quot;)));</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>Connection conn = null;</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>JsonRpcServer server = null;</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>     </span></span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span>conn =
connFactory.newConnection();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span>final
Channel ch = conn.createChannel();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span>String
positionsServerRPCQueueName = props.getProperty(&quot;PositionsServerRPCQueueName&quot;);</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>ch.queueDeclare(positionsServerRPCQueueName, false, false, true, null);</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span>server
= new JsonRpcServer(ch, positionsServerRPCQueueName,
IPositionsServerServicesInternal.class, new PositionsServerServicesInternalWrapper(positionsServerServicesImpl));</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>     </span></span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>  </span><span>      </span><span>    </span>Thread thread = new Thread(new Runnable() {</span></p>


<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>           
</span>@Override public void run() {</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>                
</span>server.mainloop();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>            </span>}</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span>});</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>       
</span>thread.start();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>    </span>}</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span></span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">My client code</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span>public
IPositionsServerServicesInternal getPositionsServerClient() {</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>        </span><span>        </span>ConnectionFactory ConnFactory = new
ConnectionFactory();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>           
</span>ConnFactory.setHost(props.getProperty(&quot;Host&quot;));</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>           
</span>ConnFactory.setPort(Integer.parseInt(props.getProperty(&quot;Port&quot;)));</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>           
</span>positionsServerClientConnection = ConnFactory.newConnection();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>           
</span>Channel channel = getToServerChannel().getChannel();</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><span>           
</span>client = new JsonRpcClient(channel, &quot;&quot;,
props.getProperty(&quot;PositionsServerRPCQueueName&quot;)); </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:&quot;Courier New&quot;;color:black"><span>    </span>}</span><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black"> </span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">On Mon, Jul 11, 2011 at 2:00
PM, Emile Joubert &lt;<a href="mailto:emile@rabbitmq.com" target="_blank">emile@rabbitmq.com</a>&gt; wrote:</span></p><div><div></div><div class="h5">

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">Hi,</span></p>

<p class="MsoNormal" dir="LTR" style="margin-bottom:12.0pt;text-align:left;direction:ltr"><span style="font-family:Arial;color:black"><br>
On 11/07/11 10:23, mysurf mail wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I have three general questions regarding rabbit java rpc<br>
&gt; 1. How should I define the client when I want to use two applications?<br>
&gt; currently i use this line<br>
&gt;                     new
JsonRpcCleint(channel,&quot;&quot;,SomeStringNotUniqueToApp)<br>
&gt; in all my apps.<br>
&gt; Sometimes the application gets stuck in the client wen trying to get the<br>
&gt; RPCClient</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">The RPC servers that serve
requests for different applications must be<br>
listening on different work queues. You must ensure that RPC clients use<br>
a routing key that matches the server queue and are different for each<br>
application.<br>
<br>
I don&#39;t see how it makes sense to use a routing key that is not unique<br>
to the application. Perhaps you can explain your intended use.</span></p>

<p class="MsoNormal" dir="LTR" style="margin-bottom:12.0pt;text-align:left;direction:ltr"><span style="font-family:Arial;color:black"><br>
&gt; 2. Is the JsonRPCClient/Server a guaranteed message delivery process?<br>
&gt; By that I am asking if when the server falls and loads again after few<br>
&gt; seconds- will it send answers ?</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">The server work queue is
normally declared outside the RPC Server<br>
framework, so you can set this up as a durable queue if you want work<br>
messages to survive a server restart.</span></p>

<p class="MsoNormal" dir="LTR" style="margin-bottom:12.0pt;text-align:left;direction:ltr"><span style="font-family:Arial;color:black"><br>
&gt; 3. Is there any way to determine timout for RPC ?<br>
&gt; I have asked it here before and received a negative answer (emile opened<br>
&gt; a bug for it - bug23515)</span></p>

<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:Arial;color:black">This feature has been added
recently and will be in the next release.<br>
</span><span style="font-family:Arial;color:#888888"><br>
<br>
-Emile</span><span style="font-family:Arial;color:black"></span></p>

<p class="MsoNormal" dir="RTL"><span dir="LTR"> </span></p></div></div></font><p></p></div></div>
</div><br></div>