- router – dealer 模式
为什么有 router – dealer 模式 ? 处理多client , 多service 的情况
1个client,多个service , 最简单的设计方法是： connect each client socket to multiple service endpoints
One client socket can connect to multiple service sockets, and the REQ socket will then distribute requests among these services. Let’s say you connect a client socket to three service endpoints; A, B, and C. The client makes requests R1, R2, R3, R4. R1 and R4 go to service A, R2 goes to B, and R3 goes to service C.
This design lets you add more clients cheaply. You can also add more services. Each client will distribute its requests to the services. But each client has to know the service topology. If you have 100 clients and then you decide to add three more services, you need to reconfigure and restart 100 clients in order for the clients to know about the three new services.
不好的地方是： client必须知道所有的service ， 当新增若干个service，每一个client 都要修改并重启
router 或者 dealer 就是在client 和 service 之间的中间层 , 用 zmq_poll() 实现： What we want is something sitting in between clients and services that centralizes all knowledge of the topology. Ideally, we should be able to add and remove services or clients at any time without touching any other part of the topology.
In this simple extended request-reply pattern, REQ talks to ROUTER and DEALER talks to REP.