Kevin Meredith
Kevin Meredith

Reputation: 41909

Async Client in ZeroMQ

Looking at http://zguide.zeromq.org/page:all#toc76's diagram:

enter image description here

As I understand, the ROUTER needs to poll frequently to hear from each of its clients.

Then, the ROUTER forwards any client message to the DEALER.

Question 1: Is the ROUTER to DEALER connection asynchronous?

Question 2: For the Server's DEALER to N DEALER Workers, must polling take place at the Server's DEALER?

Looking at the book's text:

The clients send a request once per second, and get zero or more replies back.

Question 3: I suppose the 0 comes from a Worker that dies, i.e. box/thread crashes? How could more than 1 reply return to the -Client?

Question 4: Is the DEALER to DEALER commununication synchronous?

Upvotes: 0

Views: 878

Answers (1)

David
David

Reputation: 1530

Q1: there is no connection, its code, something like :

while(router.receive(x))
{
    dealer.send(x)
}

Note : not real code, need to deal with routing info and tagging end frame etc.

Q2: Yes, assuming your workers respond to the requests. If the workers are sending replies and you don't poll at the server's dealer then the workers will eventually block when they hit the 'high water mark' for queued messages.

Q3: Depends on use case. Dealer/Router sockets have no conditions of the number of messages sent/received ( unlike REQ/REP which is 1:1 ). For example if the task done by the worker can take a long time you may want to send intermediate 'x% complete' messages.

Q4: See answer to Q3 and I'll add : depends if you want it to be. The sockets don't force it, you can code it to be sync or async.

Upvotes: 1

Related Questions