0

I have a PUSH/PULL Pattern in 0MQ (Python->C#) with just one PUSH Socket and one PULL Socket. As long as both are connected, no matter how long it takes for the worker to process the message, the order of the queued messages is preserved.

The problem is when the worker is disconnected for a while and then reconnects, then all the messages that were queued in this period will arrive in any random order, no matter how were they queued by the PUSH Socket. Is there a built-in solution for this problem or should I use a more advanced pattern?

I add the code on the PULL side:

using (var receiver = new PullSocket())
            {
                receiver.Bind("tcp://localhost:5557");

                while (true)
                {
                    var payload = receiver.ReceiveFrameString();

                    log.Debug($"Payload: {payload}");
                }
            }
marsop
  • 323
  • 4
  • 19
  • That actually pretty weird. zeromq doesn't guarantee order but it should be close to be ordered. Which transport are you using? – somdoron May 02 '16 at 09:12
  • I use tcp, and after more tests the ordering I receive seems completely random – marsop May 02 '16 at 09:19

1 Answers1

1

I am quite sure that 0mq PUSH/PULL does not guarantee order of delivery.

Maybe you can do REQ/REP (or REQ/ROUTER or a similar pattern) instead - REQ/REP can be very useful when you need to synchronize things. Out of the top of my head, you can have an in-process PUSH/PULL queue from which you pull messages and push them into a REQ socket.

shevron
  • 3,463
  • 2
  • 23
  • 35