<div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">mysurf mail</b> <span dir="ltr"><<a href="mailto:stammailbox@gmail.com">stammailbox@gmail.com</a>></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 <<a href="mailto:emile@rabbitmq.com">emile@rabbitmq.com</a>><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' 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'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:"Courier New";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:"Courier New";color:black"><br></span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";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:"Courier New";color:black"><span>
</span>connFactory.setHost(props.getProperty("Host"));</span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><span>
</span>connFactory.setPort(Integer.parseInt(props.getProperty("Port")));</span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";color:black"><span> </span>String
positionsServerRPCQueueName = props.getProperty("PositionsServerRPCQueueName");</span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";color:black"> </span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";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:"Courier New";color:black"> </span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";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:"Courier New";color:black"><span>
</span>ConnFactory.setHost(props.getProperty("Host"));</span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><span>
</span>ConnFactory.setPort(Integer.parseInt(props.getProperty("Port")));</span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";color:black"> </span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-size:10.0pt;font-family:"Courier New";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:"Courier New";color:black"><span>
</span>client = new JsonRpcClient(channel, "",
props.getProperty("PositionsServerRPCQueueName")); </span></p>
<p class="MsoNormal" dir="LTR" style="text-align:left;direction:ltr"><span style="font-family:"Courier New";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 <<a href="mailto:emile@rabbitmq.com" target="_blank">emile@rabbitmq.com</a>> 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>
> Hi,<br>
><br>
> I have three general questions regarding rabbit java rpc<br>
> 1. How should I define the client when I want to use two applications?<br>
> currently i use this line<br>
> new
JsonRpcCleint(channel,"",SomeStringNotUniqueToApp)<br>
> in all my apps.<br>
> Sometimes the application gets stuck in the client wen trying to get the<br>
> 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'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>
> 2. Is the JsonRPCClient/Server a guaranteed message delivery process?<br>
> By that I am asking if when the server falls and loads again after few<br>
> 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>
> 3. Is there any way to determine timout for RPC ?<br>
> I have asked it here before and received a negative answer (emile opened<br>
> 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>