Skip to main content

ali rocketMQ for python

说明

官方so路径要加到LD_LIBRARY_PATH中

调用示例

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : HaiFeng
# @Email   : 24918700@qq.com
# @Time    : 2019/1/16
# @desc    : demo ali rocketmq

import sys
import time
from py_rmq.rmq_consumer import Consumer
from py_rmq.rmq_producer import Producer
from py_rmq.rmq_consumer import OrderConsumer
from py_rmq.rmq_producer import OrderProducer

def OnConsumer(topic: str, tag: str, key: str, id: str, deliver_time: int, body: str, reconsume_times: int, store_time: int, offset: int):
    print(body)


if __name__ == '__main__':

    t:str = ''
    id:str = ''
    access:str = ''
    secret:str = ''
    topic:str = ''

    if len(sys.argv) > 1:
        t = sys.argv[1].lower()
        if len(sys.argv) > 2:
            id = sys.argv[2]
            if len(sys.argv) > 3:
                access = sys.argv[3]
                if len(sys.argv) > 4:
                    secret = sys.argv[4]
                    if len(sys.argv) > 5:
                        topic = sys.argv[5]
    if t == '':
        t = input('select consumer or producer:').lower()
    if id == '':
        id = input('input cid or pid:')
    if access == '':
        access = input('input acces key:')
    if secret == '':
        secret = input('input secret key:')
    if topic == '':
        topic = input('input topic:')
    if t == 'consumer':
        print('test consumer...')
        c = Consumer(id, access, secret)
        c.OnConsumer = OnConsumer
        c.subscribe(topic, '*')
        input('press enter to continue test order consumer')
        c.close()

        print('test order consumer...')
        c = OrderConsumer(id, access, secret)
        c.OnConsumer = OnConsumer
        c.subscribe(topic, '*')
        input('press enter exit')
        c.close()
    else:
        tag = 'tag test'

        key = time.strftime('%Y%m%d%H%M%S', time.localtime())

        print('test producer...')
        p = Producer(id, access, secret)
        msg = input('input content: ')
        rst = p.send_msg(topic, tag, key, msg)
        print(f'result: {rst}')
        print('test delive msg, delive 30s')
        rst = p.send_msg(topic, tag, key, msg + 'delive', int(time.time() * 1000) + 30000)
        print(f'delive msg result: {rst}')
        p.close()

        input('press enter continue test order producer')
        p = OrderProducer(id, access, secret)
        sharding_key = input('input sharding_key: ')
        rst = p.send_msg(topic, tag, key, msg, sharding_key)
        print(f'order msg result: {rst}')
        p.close()

Metadata

Release files for py-rmq 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-rmq 0.0.5
File Size Uploaded Provenance
py_rmq-0.0.5.tar.gz 26.9 kB Without provenance Details

Release files / py_rmq-0.0.5.tar.gz

Download URL py_rmq-0.0.5.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d3a54eebb3b3c99eaf6ba3c379c8606638289a5d97fa9e2b33ef6d3f5c5f4771
BLAKE2b-256 checksum
How to use checksums
837f5e10b63451a36de67dd9b3e12cb3bdb25a1ece87afa9bfd43b68ad0367cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Security for py-rmq 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.5 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page