Thanks for your reply,
In my use case, the client requests are sequential and depend on each other. 
which means when server receives a request from the client, it will decide what 
to do based on previous requests received from that client. Also, each request 
must have a reply and the client will send next request based on the reply 
receives from the server.

Right now, I am using the example provided in the online guide. 
(http://zguide.zeromq.org/pl:mtserver)
This example almost do what I want, but in the following line, it asks for a 
round robin queue:
zmq_device (ZMQ_QUEUE, $clients, $workers);

Is there any way to implement my own queuing algorithm instead of ZMQ_QUEUE?

Thanks
Jerry


________________________________
 From: Pieter Hintjens <[email protected]>
To: Hamed Afshar <[email protected]>; ZeroMQ development list 
<[email protected]> 
Sent: Wednesday, May 15, 2013 5:45 PM
Subject: Re: [zeromq-dev] sending and receiving multiple messages and replies 
from same thread
 

Two answers here. The first is, read the Guide or buy the ZeroMQ book
from O'Reilly, work through the examples, and you'll learn what you
need.

Second answer: what you are trying to do is probably wrong (and this
is very common for people who haven't yet digested how 0MQ works).
Creating one thread per client is a classic BSD socket pattern but not
common for 0MQ apps. You don't explain enough about your use-case to
know what the right direction is.

So I'd really suggest reading the Guide and building enough throw-away
examples to internalize the way it all works. Then, probably a ROUTER
for the server, a DEALER for the clients.

-Pieter





On Wed, May 15, 2013 at 2:14 PM, Hamed Afshar <[email protected]> wrote:
> Hi,
> I want to use zeromq for the following scenario, but can't recognize the
> proper pattern for this.
> Server listens to port 5555. When a client connects to server, thread A
> handles this connection and from now on, every request from client goes to
> thread A, and thread A sends a reply to the client.
>
> Currently, I am using normal req/rep pattern with Router/Dealer on top to
> handle multithreading. but every request from a client is round robined and
> load balanced between thread. What I need, is that when a thread answers the
> first request from a client, from now on, the same thread answer the rest of
> the requests from that client. (like having a persistent connection with
> client).
>
> Is this scenario possible with ZMQ? if yes, how?
>
> Thank you very much for your assistance,
> Jerry
>
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to