zeromq / jzmq

Java binding for ZeroMQ
http://www.zeromq.org
GNU General Public License v3.0
589 stars 363 forks source link

ZMsg send method doesn't return status #452

Open brinal12m opened 7 years ago

brinal12m commented 7 years ago

ZMsg has send method with void as return type. Whereas Socket api provides the boolean status for send success or failure. ZFrame has the same. Good to add ZMsg send with boolean return type.

public boolean send(Socket socket) public boolean send(Socket socket, boolean destroy)

I have written the same, kindly let me know if I can raise an PR.

Thanks, Brinal

brinal12m commented 7 years ago

Changed method as below : public boolean send(Socket socket) { return send(socket, false); }

and

public boolean send(Socket socket, boolean destroy) { boolean sendSuccess=true; if (socket == null) throw new IllegalArgumentException("socket is null"); if (frames.size() == 0) return true; Iterator<ZFrame> i = frames.iterator(); while (i.hasNext()) { ZFrame f = i.next(); sendSuccess = sendSuccess && f.send(socket, (i.hasNext()) ? ZMQ.SNDMORE : 0); //one of the frame failed. Do we need to send the next frames. if(!sendSuccess) break; } if (destroy) { destroy(); } return sendSuccess; }

Points to note here: If any ZFrame is failed, should we abandon the next set of ZFrames. What can be the impact here? previous ZFrame has was sent with SNDMORE flag. Should we destroy the ZFrames in this case??