异步任务。哪个架构? (或模式在zeroMQ) [英] Asynchronous tasks. Which architecture? (Or pattern in zeroMQ)

查看:295
本文介绍了异步任务。哪个架构? (或模式在zeroMQ)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Linux(服务器)主机上的一个应用程序与虚拟机中Win7(客户端)上的应用程序通信。选择的是ZeroMQ。但是如何管理异步任务?

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?

让我举个例子:
VM中的应用程序以任意间隔生成任务并将其发送到Linux框。这将处理它们,但需要一些时间来回答。此时,REQ / REP模式中的套接字被阻止,并且来自WinApp的传入任务无法转发到LinuxApp。我应该如何解决这个问题?这是如何解决,即使没有0MQ。

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?

要求:


  • 客户端是唯一的任务生成器。

  • 服务器为每个连接的客户端创建一个工作线程。

  • 服务器在客户端

  • - (通过一个套接字在每个客户端 - 工作线程对之间的REQ / REQ)

  • 服务器必须转发传入任务

  • 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).

因此,它不可能实现REQ / REP / REQ / REP / ...序列。

Hence its not possible to achieve the REQ/REP/REQ/REP/... sequence.

推荐答案

ZMQ指南中介绍的几种模式,看看它们中的一个是否比简单 REQ / REP

Have a look at the several patterns described in the ZMQ Guide and see if one of them fits better than simple REQ/REP.

一般来说,您的服务器在linux上似乎需要实现 ROUTER / DEALER 模式,它会将传入的任务转发给一组工人。

In general your server on the linux box seems to need implementation of ROUTER/DEALER pattern that will forward incoming tasks to a set of workers.

ZMQ与传统的基于套接字的客户端/服务器解决方案。其他解决方案可能是实现一个基于套接字的服务器,它使用线程池转发传入的任务。

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:
你一直在考虑你的要求我认为majordomo模式可能是一个良好和可靠的起点为您的目的。在他的评论中可能有更适合的模式作为@gvd提及。

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.

这篇关于异步任务。哪个架构? (或模式在zeroMQ)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆