Is it possible to add an event handling to ZeroMQ to act when data is received/sent?

不问归期 提交于 2019-12-06 08:12:56

No.

In as-is state, ZeroMQ does not implement either a trigger nor a callback.

Why?

Because the core Messaging mindset is to use Queues, not to disturb the flow of the processes, unless the processes themselves find it feasible to ask the Queue ( be it using a smart way, testing via .poll(), or in a dumb way, by a straight call to .recv( ZMQ_NOBLOCK ) ), if there are any messages ready and waiting for their post-processing and will then start to .recv() them from the ZeroMQ-side thread(s) and its resources & process them on their own process' footprint and work-flow.


But POSIX SIGNAL-s mechanics change The Rules of the Game:

Given the facts about the ZeroMQ per-se, the SIGUSR1 can deliver an independent ( just context-of-use aligned ) "Out-of-Band" signal to the receiving-process, that the sender-process has just marshaled some communication to be processed, sent and delivered down the road, so the receiving process may activate and follow the tools & methods for .recv()-ing data from the ZeroMQ delivery-path, in spite of the fact, that ZeroMQ mechanics does not provide call-back methods on its own.

So in this sense, that even the imperative language implementation of the algorithm becomes context-of-use aware about the success / failure of the last ZeroMQ call, the O/S POSIX signalling layer ( fully independent of the distributed ZeroMQ messaging / signalling delivery infrastructure ) can provide such sought means of inter-process coordination aimed at working among even sleeping / daemon instances of process-networks under test.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!