Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

消费失败重试机制不起作用 #48

@q2044757581

Description

@q2044757581
def test_push_consumer_reconsume_later():
    stop_event = threading.Event()
    raised_exc = threading.Event()

    def on_message(msg):
        print(msg.body.decode('utf-8'))
        if not raised_exc.is_set():
            raised_exc.set()
            raise Exception('Should reconsume later')
        stop_event.set()

    consumer = PushConsumer('xxxx')
    consumer.set_namesrv_domain('http://onsaddr-internet.aliyun.com/rocketmq/nsaddr4client-internet')
    # For ip and port name server address, use `set_namesrv_addr` method, for example:
    # consumer.set_namesrv_addr('127.0.0.1:9887')
    consumer.set_session_credentials('LTAI0Dl0VYPDiExz', 'KOFlHDMPlVboJPbBcy07wkGO6rRyeB',
                                     'ALIYUN')  # No need to call this function if you don't use Aliyun.
    consumer.subscribe('xxxxx', on_message, 'hello')
    consumer.start()
    while not stop_event.is_set():
        time.sleep(10)


test_push_consumer_reconsume_later()

我按照你的代码这样测了,但是抛了异常的那条消息并不会再来第二次,按理说应该会再来第二次然后停止阻塞终止程序的对吧?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions