Overview Tutorial API reference Examples Build Download | ZmqMessage 0.1 - 21 Oct 2011 |
This feature is useful when:
In this case we should create outgoing messages with ZmqMessage::OutOptions::NONBLOCK and ZmqMessage::OutOptions::CACHE_ON_BLOCK. If sending fails, we may 'detach' composed message and resend it later, when output socket will be available for writing.
//delayed queue std::vector<Zmqmessage::Multipart*> queue; zmq::socket_t s_req(ctx, ZMQ_PUSH); //set HWM uint64_t lim = 10; s_req.setsockopt(ZMQ_HWM, &lim, sizeof(uint64_t)); s_req.connect("inproc://test-ep"); ZmqMessage::OutOptions opts(s_req, ZmqMessage::OutOptions::CACHE_ON_BLOCK | ZmqMessage::OutOptions::NONBLOCK); ZmqMessage::Outgoing<ZmqMessage::SimpleRouting> egress(opts); egress << "finished" << 888 << ZmqMessage::Flush; if (egress.is_queued()) { queue.push_back(egress.detach()); }
See example zasync for details.
Note, that currently queueing functionality has proven working only for PUSH-PULL sockets. Request-reply patterns (REQ, RES, XREQ, XRES sockets) in many cases prevent congestion due to internal socket states.