[zeromq-dev] Using zeromq pub/sub with persistant identities

Ross McKillop ross at rsmck.co.uk
Tue Aug 7 19:16:52 CEST 2012

Hi All,

I've got a relatively simple application (i think) for zeromq.  Essentially I'm trying to
generate messages from X number of servers and capture them on one central one
(similar to a centralised log server perhaps)

There are two parts;

The individual publishers which currently use SOCKET_PUB with a SOCKET_IDENTITY
set and bind to a local TCP port

The central subscriber which creates a SOCKET_SUB with the same SOCKET_IDENTITY
and initiates an outbound connection to all of the publishers then uses a POLL to poll
them for updates.

This works - however the subscriber must know about each publisher in it's own code
(there's a connect line for each) and adding/removing a server involves restarting the
subscriber, also it just seems like I'm going about it the wrong way.

What I had hoped to do was to have the subscriber listen on a port, and allow any 
number of publishers to connect.  This does work, but loses the 'backlog' of messages
i.e. if the subscriber goes down for any reason, the publishers do not seem to reconnect
and resend 'lost' messages when it comes back.

Whereas at present if I stop the subscriber and then restart it - any messages generated
by the publishers will be queued up and received (i.e. none are lost)

Any advice anyone could offer would be useful - ideally I want to achieve two things;

	The subscriber should receive connections from other hosts (rather than
	connect outwards to them) 

	If the subscriber fails for any reason, when restarted it should receive any
	messages that were generated in the interim.

I can't help but feel I'm missing something obvious. 

Best Regards,

More information about the zeromq-dev mailing list