Пример #1
0
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)
Пример #2
0
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)