ZMQ-SOURCE: improve readability and sustanibility fixes

 * separate some common code into a function
 * minor error handling
ZMQ-SOURCE: Added notify function

 * It will handle if something goes wrong during the sending