[zeromq-dev] questions about sub/pub socket

Guo, Yanchao Yanchao.Guo at sac.com
Tue Feb 2 09:44:03 CET 2010

Hi Martin:

Actually I want to AVOID the situation that message are cached in the publisher when the subscriber disconnected. However, with the PUB/Connect type of socket that I described below, the message is cached by default when the SUB is disconnected. I am asking is there a way to make this NOT happen. 


-----Original Message-----
From: Martin Sustrik [mailto:sustrik at 250bpm.com]
Sent: Tue 2/2/2010 3:42 AM
To: Guo, Yanchao
Cc: zeromq-dev at lists.zeromq.org
Subject: Re: [zeromq-dev] questions about sub/pub socket
Guo, Yanchao wrote:
> Hi Martin:
>  From my experient, I found that if I setup up socket in this way:
> m_Context = new context_t(1,1);
> m_Socket = new socket_t(*m_Context, ZMQ_PUB);
> m_Socket->connect(port);
> and then send message through this socket, then the message will be 
> queued in the socket, in a sense that if the SUB socket (which binds to 
> the port) starts later then this PUB socket, the SUB socket is able to 
> receive all the historical data.
> This behavior is different from a PUB socket which bind to a port, in 
> that case the is no historical data kept.
> Is it possible to make the PUB/connecting socket not caching the data?

I assume you are trying to ensure that the messages are stored in 
publisher when your subscriber disconnects for a while, right?

If so, set ZMQ_IDENTITY option on your subscriber socket. That way the 
publisher will know that subsequent TCP connections belong to the same 
peer application. It'll store messages during the time the application 
is disconnected and send them once it gets back online.

> Also, is there a onInit method to notify the server of newly established 
> connection?



DISCLAIMER: This e-mail message and any attachments are intended solely for the use of the individual or entity to which it is addressed and may contain information that is confidential or legally privileged. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and permanently delete this message and any attachments. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100202/83ee92c6/attachment.htm>

More information about the zeromq-dev mailing list