1. About the introduction of the ZEROMQ, you can go to see the official guide very detailed 2. The main point is that in the use of the process to pay attention to the place 1 use if you use C + + interface, in your own class or Apache modules need to be zmq::context_t object is defined in front of the zmq::socket_t object, which guarantees the order of the destruction
2 when using Sub-pub, if sub does not call the SetSockOpt settings filter (set NULL to accept All), then no messages will be received and all messages will be blocked by default
3 If the background service cluster use and ZMQ need bind port, then it is best to filter in the iptables, do not let the external chain to take over, otherwise it will cause CPU idling; About CPU idling will be at the end say
4 When the client connects to the server, ZMQ in each client, each connection uses a socket, although a socket can call connect multiple times, that is, to connect multiple servers. However, remember that it is best to have a socket call only once connect
5 Use ZMQ program, run after a period of time (perhaps a few days), if you encounter an abnormal exit, and you use the Nohup run log nohup.out display ZEROMQ connection Timeout, then you can zeromq/src/tcp_ The 203 lines in the Socket.cpp file see an error when write.
int zmq::tcp_socket_t::write (const void *data, int size)
{
ssize_t nbytes = Send (s, data, size, 0); several errors are OK. When speculative write is being do we not
//be able to write a single byte to the socket. Also, SIGSTOP issued
//by A debugging tool can result in eintr error.
if (nbytes = = 1 && (errno = = Eagain | | | errno = = Ewouldblock | |
errno = = eintr)) return
0; Signalise peer failure.
if (nbytes = = 1 && (errno = = Econnreset | | | errno = = epipe))
return-1;
Errno_assert (nbytes!=-1);
Return (size_t) nbytes;
}
This is due to Errno_assert (nbytes!=-1); But the real reason is nbytes==-1 when errno==etimedout, in the previous line, did not add to the judgment of this timeout, in addition, You can refer to the deal on win in this file. So if you have a timeout error here, add errno = = Etimeout to Errno==epipe and recompile
6 about CPU idling. First you can use the top program name, to see if the CPU usage of your program is 100%, and basically fixed, then you need to doubt whether your program's problems, and then through the LSOF-P program process number, to see if there are file descriptors have can ' t identify Protocol, also notice whether there is an extranet IP connection to your ZMQ listening port. Then, you can log in the LOOP,RM_FD,ADD_FD function in Zeromq/src/epoll.cpp to see if you hear epollerr| in the monitor. The Epollhup file descriptor is not the same as the file descriptor of the can ' t identify protocol lsof-p look up. In fact, as long as the front 5 points, then the CPU idling basically will not appear.
PS: Finally, I hope to encounter problems, we can think of why there is such a problem, how to solve, for their own promotion will have a great help