def demo_msg_mysql2ftp(): msg = MSG() msg.origination = URL().init("mysql").check msg.destination = URL().init("ftp").check msg.treatment = URL().init("tcp") case = CASE() case.origination = msg.origination case.destination = msg.destination msg.activity = "init" msg.case = case msg.add_datum("This is a test string", path=URL().init("file")) msg.add_datum("中文UTF-8编码测试", path=URL().init("file")) path = "..\README\Babelor-设计.png" with open(path, "rb") as f: bytes_f = f.read() url = URL().init("file") url.path = path msg.add_datum(bytes_f, url) msg_string = str(msg) new_msg = MSG(msg_string) new_bytes_f = new_msg.read_datum(3)["stream"] new_path = "..\README\Babelor-设计-new.png" with open(new_path, "wb") as f: f.write(new_bytes_f)
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 try_reply_func(msg: MSG): msg.destination = URL().init("oracle") return msg
myself.open(role="encrypter", func=func_encrypter) 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")