[zeromq-dev] clrzmq - sending kill request to other threads

Seif Attar iam at seifattar.net
Sun Feb 26 03:09:04 CET 2012

Forgot to mention the errors I am getting, I get 2 exceptions at
different times:


On 25 February 2012 23:23, Seif Attar <iam at seifattar.net> wrote:
> Hello,
> I am trying to write a logger for NHibernate that will pulish log
> messages with 0mq, each logger might be used from a different thread.
> The way I implemented this is by started a running thread with a PULL
> inproc socket that will get the messages from the logger and publish
> them using tcp.
> Each of the loggers creates a push socket that sends messages to the
> sink running in the main publisher thread.
> This works ok, only problem I am having is that I can't dispose of the
> objects properly, I need a way to send a kill signal to the loggers
> before terminating the context. I looked at how this should be done,
> and it would appear that I need to  have a controller in the main
> thread that sends the kill signal to another socket on the logger
> (something along the lines of http://zguide.zeromq.org/cs:tasksink2
> and http://zguide.zeromq.org/cs:taskwork2). However, this means that
> the loggers will block the caller, which won't work.
> Any recommendations on how to go about this? The code is on github:
> The class that holds the main thread is:
> https://github.com/seif/NHibernate.ZMQLogPublisher/blob/master/src/NHibernate.ZMQLogPublisher/Publisher.cs
> and the logger:
> https://github.com/seif/NHibernate.ZMQLogPublisher/blob/master/src/NHibernate.ZMQLogPublisher/ZmqLogger.cs
> This is the Logger factory which Nhibernate calls into, nothing 0MQ
> specific in here:
> https://github.com/seif/NHibernate.ZMQLogPublisher/blob/master/src/NHibernate.ZMQLogPublisher/ZmqLoggerFactory.cs
> I had tried opening a new Socket in each ZMQLogger.Publish call, but
> that caused an exception (Too many files open), understandble, so I am
> back at  having to send the kill signal.
> Any help appreciated.
> Thanks,
> Seif

More information about the zeromq-dev mailing list