[zeromq-dev] "multiplexing" an asynchronous API

ramesh adroitus at gmail.com
Fri Dec 9 18:02:39 CET 2011


On 12/09/2011 08:16 AM, Tom Bennett wrote:
> Hi,
> I have an asynchronous API that is like a request-subscription: I 
> call a function to request subsciption of a topic, and my call-back 
> function will be called when events for the topic arrive. Note that it 
> is not possible to lose any mesage because it is a call-back.
> Now I would like to put this API behind a server, so that multiple 
> clients living in separate processes can call the server which in turn 
> calls the API. I am wondering how tis can be implemented with 0mq. I 
> have several ideas:
> 1. I can use PUB/SUB and REQ/REP. First the client subscribes to the 
> PUB socket and then the client sends the request through 
> REQ/REP. There are two problems: 1) I am not sure how I can make sure 
> the PUB/SUB is ready before sending the REQ so that I won't lose any 
> messages; 2) the PUB/SUB filter is on the client side, which might be 
> an issue.
> 2. I can use PUSH/PULL and REQ/REP. The problem here is that for each 
> client I will have to create a new PUSH socket on the server.
> 3. I can just use REQ/REP. If the API call-back is called once and 
> only once, this actually works beautifully. However, if it is a 
> situation where I send a request and there are multiple asynchronous 
> responses, this does not seem to work.
> Any advices on how to handle this situation?
> Thanks,
> Tom
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Hi Tom,

 From what I understand Pub/Sub is what you need.
Multiple clients can create multiple subscriptions. However you need to 
take a look at the Thread Saftey.
http://api.zeromq.org/2-1:zmq

When message arrives, you want your subscriber to let you know.
Now , I  have been trying to figure out the best way to do this.
I think you need to take a loot at zmq_poll 
<http://api.zeromq.org/2-1:zmq-poll>

HTH
regards,
Ramesh


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20111209/3c473a08/attachment.htm>


More information about the zeromq-dev mailing list