[zeromq-dev] first message never received when SUB binds (0MQ 3)

Martin Sustrik sustrik at 250bpm.com
Tue Sep 6 10:02:35 CEST 2011


On 09/04/2011 08:47 PM, MinRK wrote:
> When binding with SUB, and connecting with PUB, it seems impossible to
> receive the first message.

This is caused by introduction of subscription forwarding. The scenario 
goes like this:

1. subscriber connects to the publisher
2. publisher starts sending messages
3. there's no filter so far, so the messages get dropped
4. subscriber subscribes
5. from this point on the messages are delivered

The real problem behind the issue is mixing the "message distribution" 
and "message aggregation" patterns in what's PUB/SUB pattern today. In 
the former the above behaviour is expected (you get only the messages 
after you've asked for them, old messages will never be delivered). In 
the latter there's a reliability requirement, but there's no need for 
subscriptions, which would make the problem disappear.

As a quick hack, the problem can be solved by introducing a new "start" 
command to be sent from subscriber to the publisher:

1. subscriber connects to the publisher
2. it sends all the active subscriptions to the publisher
3. it sends the "start" command to the publisher
4. publisher start sending messages to the consumer

Thoughts?
Martin



More information about the zeromq-dev mailing list