Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZeroMQ design decisions

In a REQ/REP socket, if the socket send a request to a dead (disconnected) node the message isn't delivered and stays in a message queue occupying memory. How can one clean these undelivered messages (let's say, messages that are in the queue for more than 1 minute)?

Thanks!

like image 750
carlosalbertomst Avatar asked Sep 28 '10 19:09

carlosalbertomst


People also ask

What is ZeroMQ used for?

ZeroMQ is a library used to implement messaging and communication systems between applications and processes - fast and asynchronously.

What protocol does ZeroMQ use?

The ZeroMQ Message Transport Protocol (ZMTP) is a transport layer protocol for exchanging messages between two peers over a connected transport layer such as TCP. This document describes ZMTP/2.0. In theory, ZMTP should define fully interoperable behavior between implementations.

What is a ZeroMQ connection?

ZeroMQ (also spelled ØMQ, 0MQ or ZMQ) is an asynchronous messaging library, aimed at use in distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ZeroMQ system can run without a dedicated message broker; the zero in the name is for zero broker.

Does ZeroMQ use TCP or UDP?

To begin, instead of being stream (TCP), or datagram (UDP) oriented, ZeroMQ communication is message-oriented. This means that if a client socket sends a 150kb message, then the server socket will receive a complete, identical message on the other end without having to implement any explicit buffering or framing.


1 Answers

You might want to set the optional parameter ZMQ_LINGER:

The ZMQ_LINGER option shall set the linger period for the specified socket. The linger period determines how long pending messages which have yet to be sent to a peer shall linger in memory after a socket is closed with zmq_close(3), and further affects the termination of the socket's context with zmq_term(3).

... for which a positive value will set a maximun time for message to be blocked in the queue.

See http://api.zeromq.org/2-1-1:zmq-setsockopt

like image 142
Manuel Salvadores Avatar answered Sep 22 '22 01:09

Manuel Salvadores