问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/10062104/pulling-requests-from-multiple-clients-with-zmq