[zeromq-dev] clrzmq - sending kill request to other threads
iam at seifattar.net
Sun Feb 26 00:23:14 CET 2012
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:
and the logger:
This is the Logger factory which Nhibernate calls into, nothing 0MQ
specific in here:
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.
More information about the zeromq-dev