I want one application on a Linux(Server) host to communicate with applications on Win7(Client) in a VM. Lib of choice is ZeroMQ. But how do I manage asynchronous tasks?
Let me give an example:
The application in the VM generates tasks in arbitrary intervals and sends them to the Linux box. This will process them but needs some time to answer. In this time the socket in REQ/REP pattern is blocked and incoming tasks from the WinApp can not be forwarded to the LinuxApp. How should I solve this? How is this generally solved, even without 0MQ. Do I have to make both to servers and clients and establish two connections?
Requirements:
- A client is a unique task generator.
- Server creates a workerthread for each connecting client.
- Server establishes a unique connection between client an workerthread.(Some tunnle)
- -> (REQ/REQ between each client-workerthread pair over one socket)
- Server must forward incoming tasks instantly.
- Server must be able to handle multiple clients (and therefore connections to WTs).
Hence its not possible to achieve the REQ/REP/REQ/REP/… sequence.
Have a look at the several patterns described in the ZMQ Guide and see if one of them fits better than simple
REQ/REP.In general your server on the linux box seems to need implementation of
ROUTER/DEALERpattern that will forward incoming tasks to a set of workers.ZMQ has it’s own topology compared to traditional socket based client/server solutions. Other solutions might be to implement a socket based server that uses a thread pool to forward the incoming tasks.
UPDATE:
Since you’ve been precising on your requirements I think the majordomo pattern might be a good and reliable starting point for your purposes. There might be better fitting patterns as @gvd mentions in his comments.