使用 ZMQ 从多个客户端拉取请求 [英] Pulling requests from multiple clients with ZMQ

查看:56
本文介绍了使用 ZMQ 从多个客户端拉取请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个工人在等着做一些工作.我看到在 PULL/PUSH 模式中,我需要为工作人员提供客户端的 ip 地址(使用 tcp 协议),以便它可以侦听来自那里的请求.但是,在我的情况下,我也希望有很多客户端,来自不同 IP 的请求......所以基本上我真的没有一个静态 IP 来绑定工作人员到 PULL.我是使用了错误的模式还是有正确的方法?

I have a couple of workers waiting to do some jobs. I see that in the PULL/PUSH pattern I need to give the workers the ip address (using the tcp protocol) of the client, so it can listen to requests from there. However, in my case I want to have a lot of clients as well, coming from different IPs with requests... So basically I dont really have a static IP to bind the worker to PULL from. Am I using the wrong pattern or is there a way to do it correctly?

推荐答案

您应该考虑使用路由器经销商模式.您的路由器绑定在 2 端,它有一个静态 IP.它从连接到它的多个客户端中拉取并推送到另一端的工作人员.您可以使用 ROUTER/DEALER 套接字类型来实现这一点,也可以使用使用 PUSH/PULL 套接字的额外桥接器将客户端连接到工作程序.

You should consider using the router-dealer pattern. Your router binds at 2 ends and it has a static IP. It pulls from the multiple clients that connect to it and pushes to the workers on the other end. You can use the ROUTER/DEALER socket types to make this or just use an extra bridge using PUSH/PULL sockets to connect the clients to the workers.

这篇关于使用 ZMQ 从多个客户端拉取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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