[zeromq-dev] Weird zmq_receive behavior on blocking

Pavol Malosek malosek at fastmq.com
Thu Jul 2 18:35:15 CEST 2009

Hello Sean,

The problem you are seeing is caused by using single zmq api by the two
application threads.
The rule is to have zmq api in each application thread.
zmq::api_thread_t (3)

The API thread is a proxy for an application thread to access 0MQ
For each of your application threads that needs to use 0MQ you should create
an instance of the api_thread class.


            Message msg = new Message();
            msg.Callback = WeGotIt;
            msg.CommandID = DateTime.Now.Ticks;
            msg.CommandName = "Create Project";
            msg.ID = 10;
            msg.SourceHostID = 0;
            msg.SystemType = 1;
            msg.TargetHostID = 1;
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  Message should be send from
requestor thread and not from here!

Moreower, would be better to start threads in order manager, worker and then

One issue which could possibly cause your initial problems has been solved
meanwhile (r1556).
Anyway, when _requestorQ.Send call was moved to requestor thread we could
get full message roundtrip in 100% tries.

Please let us know if it works for you.


----- Original Message -----
From: "Sean McKay" <sean at on-track-solutions.com>
To: "'Martin Sustrik'" <sustrik at fastmq.com>
Cc: <zeromq-dev at mail.imatix.com>
Sent: Thursday, June 18, 2009 4:38 PM
Subject: Re: [zeromq-dev] Weird zmq_receive behavior on blocking

> This version only has the C# code so as to fit under the ML constraints...
> -----Original Message-----
> From: Sean McKay [mailto:sean at on-track-solutions.com]
> Sent: Tuesday, June 16, 2009 3:37 PM
> To: 'Martin Sustrik'
> Cc: 'zeromq-dev at mail.imatix.com'
> Subject: RE: [zeromq-dev] Weird zmq_receive behavior on blocking
> Hi Martin,
> I apologize for the long delay.  I am behind on a number of tasks, and
> got a chance to make a "small" subset of the code that reproduces the bug.
> I regret I don't have the time to make it even shorter.
> There is a slight difference between the possible bug I originally
> and what this application shows -- it doesn't reveal itself until the last
> step in the round trip.  So it will go from Request to Manager to Worker
> Manager and stop there for some reason.  The original issue I reported
> stopped between the Worker sending to the Manager.
> To turn on the bug (the non-blocking _working_ version is currently used)
> switch:
> _zmqServer.Receive(out inMessage, out type, false);
> To
> _zmqServer.Receive(out inMessage, out type, true);
> Thanks,
> Sean

More information about the zeromq-dev mailing list