[rabbitmq-discuss] Fwd: a few json rpc questions

mysurf mail stammailbox at gmail.com
Wed Jul 13 14:28:42 BST 2011


---------- Forwarded message ----------
From: mysurf mail <stammailbox at gmail.com>
Date: Wed, Jul 13, 2011 at 4:27 PM
Subject: Re: [rabbitmq-discuss] a few json rpc questions
To: Emile Joubert <emile at rabbitmq.com>


Hi Emile,

Thanks for the assistance.

Though I have read the tutorial in your site, it looks like I did not fully
understand the rpc for multiple clients' mechanism.



What I want is that the rpc server will serve all rpc clients.

I don't know how many clients I will have in advance.

I have a lot and some will run from the same folder with the same
configurations (more that one instance)



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.

1. Is there any way to use the rpc like that for multiple clients?
2. Would I need to give each one a different routing key?

3. Would I need to use different server threads for each client?


Thanks.


I will add my client / server code.

I would appreciate it very much if you elaborate your answer

Thank you.


My server code ( try catch keywords were removed for clarity)


    public void startListenToClients() {

        ConnectionFactory connFactory = new ConnectionFactory();

        connFactory.setHost(props.getProperty("Host"));

        connFactory.setPort(Integer.parseInt(props.getProperty("Port")));

        Connection conn = null;

        JsonRpcServer server = null;



        conn = connFactory.newConnection();

        final Channel ch = conn.createChannel();

        String positionsServerRPCQueueName =
props.getProperty("PositionsServerRPCQueueName");

        ch.queueDeclare(positionsServerRPCQueueName, false, false, true,
null);



        server = new JsonRpcServer(ch, positionsServerRPCQueueName,
IPositionsServerServicesInternal.class, new
PositionsServerServicesInternalWrapper(positionsServerServicesImpl));



            Thread thread = new Thread(new Runnable() {

            @Override public void run() {

                 server.mainloop();

            }

        });

        thread.start();

    }



My client code



        public IPositionsServerServicesInternal getPositionsServerClient() {

                ConnectionFactory ConnFactory = new ConnectionFactory();

            ConnFactory.setHost(props.getProperty("Host"));


ConnFactory.setPort(Integer.parseInt(props.getProperty("Port")));

            positionsServerClientConnection = ConnFactory.newConnection();



            Channel channel = getToServerChannel().getChannel();

            client = new JsonRpcClient(channel, "",
props.getProperty("PositionsServerRPCQueueName"));

    }













On Mon, Jul 11, 2011 at 2:00 PM, Emile Joubert <emile at rabbitmq.com> wrote:

Hi,


On 11/07/11 10:23, mysurf mail wrote:
> Hi,
>
> I have three general questions regarding rabbit java rpc
> 1. How should I define the client when I want to use two applications?
> currently i use this line
>                     new JsonRpcCleint(channel,"",SomeStringNotUniqueToApp)
> in all my apps.
> Sometimes the application gets stuck in the client wen trying to get the
> RPCClient

The RPC servers that serve requests for different applications must be
listening on different work queues. You must ensure that RPC clients use
a routing key that matches the server queue and are different for each
application.

I don't see how it makes sense to use a routing key that is not unique
to the application. Perhaps you can explain your intended use.


> 2. Is the JsonRPCClient/Server a guaranteed message delivery process?
> By that I am asking if when the server falls and loads again after few
> seconds- will it send answers ?

The server work queue is normally declared outside the RPC Server
framework, so you can set this up as a durable queue if you want work
messages to survive a server restart.


> 3. Is there any way to determine timout for RPC ?
> I have asked it here before and received a negative answer (emile opened
> a bug for it - bug23515)

This feature has been added recently and will be in the next release.


-Emile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110713/65a41ebe/attachment.htm>


More information about the rabbitmq-discuss mailing list