what is the use of ZMQueue class in JeroMQ

我们两清 提交于 2020-01-17 06:18:12

问题


I checked source code of ZMQueue class from JeroMQ which implements Runnable interface looks like:

private final Socket  inSocket;
private final Socket outSocket;

 public ZMQQueue( Context context, Socket inSocket, Socket outSocket ){
    this.inSocket  =  inSocket;
    this.outSocket = outSocket;
 }

 @Override
 public void run(){
        zmq.ZMQ.proxy( inSocket.base(), outSocket.base(), null );
 }

As you can see inside the run() only one statement is there, i.e. calling a

ZMQ.proxy() - what happens here?

And in constructor,
it's taking a Context instance as a parameter and doing nothing with it.

can any one explains, for what purpose this class has implemented?


回答1:


It's simple proxy that works in separate thread, it takes a msg from one socket and puts it to another, ZMQueue class is just a some kind of high-level api in jeromq/jzmq library.

Also you can use proxy without ZMQueue class (doc). Or you can implement something more complicated by yourself with any processing you need.



来源:https://stackoverflow.com/questions/41032230/what-is-the-use-of-zmqueue-class-in-jeromq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!