def try_push(url: str): msg = MSG() msg.origination = URL("tcp://127.0.0.1:10001") msg.destination = URL("tcp://127.0.0.1:10001") mq = MQ(url) for i in range(0, 10000, 1): # print("push msg:", msg) msg.activity = str(i) # print("push msg:", i, msg) mq.push(msg)
def priest(conn: URL, queue_ctrl: Queue, pipe_in: Pipe): mq = MQ(conn) is_active = queue_ctrl.get() while is_active: if queue_ctrl.empty(): msg_in = mq.pull() logging.info("TEMPLE::{0} pull:{1}".format(conn, msg_in)) pipe_in.send(msg_in) logging.debug("TEMPLE::{0}::PIPE IN send:{1}".format(conn, msg_in)) else: is_active = queue_ctrl.get() else: queue_ctrl.close()
def allocator(conn: URL): if conn is None: return None else: if conn.scheme in ["oracle", "mysql"]: return SQL(conn) if conn.scheme in ["tcp"]: return MQ(conn) if conn.scheme in ["ftp"]: return FTP(conn) if conn.scheme in ["ftpd"]: return FTPD(conn) if conn.scheme in ["tomail"]: return TOMAIL(conn) if conn.scheme in ["file"]: return FILE(conn)
def try_subscribe(): mq = MQ(URL("tcp://127.0.0.1:10001")) msg = mq.subscribe() print("subscribe msg:", msg)
def try_publish(): msg = MSG() msg.origination = URL("tcp://127.0.0.1:10001") mq = MQ(URL("tcp://*:10001")) print("publish msg:", msg) mq.publish(msg)
def try_reply(): mq = MQ(URL("tcp://*:10001")) mq.reply(try_reply_func)
def try_request(): msg = MSG() msg.origination = URL("tcp://127.0.0.1:10001") mq = MQ(URL("tcp://127.0.0.1:10001")) msg = mq.request(msg)
def try_pull(url: str): mq = MQ(url) for i in range(0, 10000, 1): msg = mq.pull() logging.warning("PULL::{0} seq:{1} recv:{2}".format( url, i, msg.timestamp))
def receiver(url): myself = TEMPLE(url) myself.open(role="receiver") def receiver_init(): # -————————————------------------------ MESSAGE ----- case = CASE("{0}#{1}".format(origination_url, destination_url)) receiver_msg = MSG() receiver_msg.case = case # -————————————------------------------ RECEIVER ---- receiver_msg.origination = edge_node_url["inner"] receiver_msg.destination = destination_url # logging.warning("RECEIVER::INIT::{0} send:{1}".format(receiver_url["inner"], receiver_msg)) recv_init = MQ(receiver_url["outer"]) recv_init.push(receiver_msg) def sender_init(): # -————————————------------------------ MESSAGE ----- case = CASE("{0}#{1}".format(origination_url, destination_url)) sender_msg = MSG() sender_msg.case = case # -————————————------------------------ SENDER ------ sender_msg.origination = origination_url sender_msg.destination = edge_node_url["outer"] sender_msg.add_datum(None, "20190505.xlsx") sender_msg.add_datum(None, "20190506.xlsx") sender_msg.add_datum(None, "20190507.xlsx") send_init = MQ(sender_url["outer"])