def monitoredqueue(frontend_url="tcp://*:4444", server_url="tcp://localhost:5555", capture_url="tcp://*:7777"): mondev = MonitoredQueue(zmq.ROUTER, zmq.DEALER, zmq.PUB, asbytes("in"), asbytes("out")) mondev.bind_in(frontend_url) mondev.connect_out(server_url) mondev.bind_mon(capture_url) mondev.setsockopt_in(zmq.SNDHWM, 1) mondev.start() print("Monitored queue started")
def main(): in_prefix = bytes('in') out_prefix = bytes('out') monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix) monitoringdevice.bind_in("tcp://127.0.0.1:5559") monitoringdevice.bind_out("tcp://127.0.0.1:5560") monitoringdevice.bind_mon("tcp://127.0.0.1:5570") monitoringdevice.setsockopt_in(zmq.RCVHWM, 1) monitoringdevice.setsockopt_out(zmq.SNDHWM, 1) monitoringdevice.start()
def monitordevice(): in_prefix=asbytes('in') out_prefix=asbytes('out') monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix) monitoringdevice.bind_in("tcp://127.0.0.1:%d" % frontend_port) monitoringdevice.bind_out("tcp://127.0.0.1:%d" % backend_port) monitoringdevice.bind_mon("tcp://127.0.0.1:%d" % monitor_port) monitoringdevice.setsockopt_in(zmq.HWM, 1) monitoringdevice.setsockopt_out(zmq.HWM, 1) monitoringdevice.start() print "Program: Monitoring device has started"
def monitordevice(): in_prefix = asbytes('in') out_prefix = asbytes('out') monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix) monitoringdevice.bind_in("tcp://127.0.0.1:%d" % frontend_port) monitoringdevice.bind_out("tcp://127.0.0.1:%d" % backend_port) monitoringdevice.bind_mon("tcp://127.0.0.1:%d" % monitor_port) monitoringdevice.setsockopt_in(zmq.HWM, 1) monitoringdevice.setsockopt_out(zmq.HWM, 1) monitoringdevice.start() print "Program: Monitoring device has started"
def main(): in_prefix = b'in' out_prefix = b'out' monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix) # client monitoringdevice.bind_in("tcp://0.0.0.0:5559") # server monitoringdevice.bind_out("tcp://0.0.0.0:5560") # monitor monitoringdevice.bind_mon("tcp://0.0.0.0:5570") monitoringdevice.setsockopt_in(zmq.RCVHWM, 1) monitoringdevice.setsockopt_out(zmq.SNDHWM, 1) monitoringdevice.start()
def main(): in_prefix = bytes('in') out_prefix = bytes('out') monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix) # client monitoringdevice.bind_in("tcp://0.0.0.0:5559") # server monitoringdevice.bind_out("tcp://0.0.0.0:5560") # monitor monitoringdevice.bind_mon("tcp://0.0.0.0:5570") monitoringdevice.setsockopt_in(zmq.RCVHWM, 1) monitoringdevice.setsockopt_out(zmq.SNDHWM, 1) monitoringdevice.start()
def monitordevice(in_con_id, out_con_id, mon_con_id): in_prefix = asbytes('in') out_prefix = asbytes('out') monitoringdevice = MonitoredQueue( zmq.PUSH, # in zmq.PULL, # out zmq.PUB, # mon in_prefix, out_prefix) monitoringdevice.bind_in(in_con_id) monitoringdevice.bind_out(out_con_id) monitoringdevice.bind_mon(mon_con_id) monitoringdevice.start() print("Program: Monitoring device has started")
def start_monitored_queue_ZMQ(ip_addr, pub_port, sub_port, monitor_port, identifier=''): ''' This function will start ZMQ monitored queue for based on given ports, used mainly for multiprocessing.Process Input: - ip_addr -> ip address to bind, string - pub_port -> port for publisher, int - sub_port -> port for subscriber, int - monitor_port -> port for monitor, int - identifier -> identifier for the monitored queue, string Output: - Does not return ''' # Prepare our context and sockets in_prefix = asbytes(identifier + '_in') out_prefix = asbytes(identifier + '_out') try: # start the MonitoredQueue monitoring_device = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix) monitoring_device.bind_in("tcp://{ip_addr}:{pub_port}".format( ip_addr=ip_addr, pub_port=pub_port)) monitoring_device.bind_out("tcp://{ip_addr}:{sub_port}".format( ip_addr=ip_addr, sub_port=sub_port)) monitoring_device.bind_mon("tcp://{ip_addr}:{monitor_port}".format( ip_addr=ip_addr, monitor_port=monitor_port)) monitoring_device.setsockopt_in(zmq.RCVHWM, 1) monitoring_device.setsockopt_out(zmq.SNDHWM, 1) # logging print("{identifier}: Monitoring device has started".format( identifier=identifier)) # start the monitoring monitoring_device.start() # Not supposed to return, as the monitoring_device is blocking except: # have exception pass