apache / rocketmq-client-python

Apache RocketMQ python client
https://rocketmq.apache.org/
Apache License 2.0
271 stars 95 forks source link

I use this producer example to send transaction message to RocketMQ, why the check_callback callback function cannot execute? #114

Open yinhuanyi opened 3 years ago

yinhuanyi commented 3 years ago
  1. Please describe the issue you observed: I use this producer example to send transaction message to RocketMQ, why the check_callback callback function cannot execute?

  2. Please tell us about your environment:

mac os

  1. Other information (e.g. detailed explanation, logs, related issues, suggestions on how to fix, etc):
def send_transaction_message(count):
    producer = TransactionMQProducer(gid, check_callback)
    producer.set_name_server_address(name_srv)
    producer.start()
    for n in range(count):
        msg = create_message()
        ret = producer.send_message_in_transaction(msg, local_execute, None)
        print ('send message status: ' + str(ret.status) + ' msgId: ' + ret.msg_id)
    print ('send transaction message done')

    while True:
        time.sleep(3600)
yinhuanyi commented 3 years ago

producer output message like this below, check_callback function does not execute

local:   message body
send message status: SendStatus.OK msgId: 7F000001408D27F819B48AAED2170000
send transaction message done
Zzaniu commented 3 years ago

1.rocketmq == 4.8.0 2.rocketmq-client-python == 2.0.0

on_check callback function not execute

def test_transaction_producer():
    stop_event = threading.Event()
    msg_body = 'XXXX'

    def on_local_execute(msg, user_args):
        return TransactionStatus.UNKNOWN

    def on_check(msg):
        stop_event.set()
        assert msg.body.decode('utf-8') == msg_body
        return TransactionStatus.COMMIT

    producer = TransactionMQProducer('transactionTestGroup' + str(PY_VERSION), on_check)
    producer.set_name_server_address('127.0.0.1:9876')
    producer.start()
    msg = Message('test')
    msg.set_keys('transaction')
    msg.set_tags('XXX')
    msg.set_body(msg_body)
    producer.send_message_in_transaction(msg, on_local_execute)
    while not stop_event.is_set():
        time.sleep(2)
    producer.shutdown()

image

jasonlc commented 2 years ago

yinhuanyi

Have you solved this problem?

Lin-CZC commented 2 years ago

Have you solved this problem?

Zzaniu commented 2 years ago

switch to golang...

zsk1993 commented 1 year ago

I have solved this problem. if your system is mac,just: wget https://github.com/apache/rocketmq-client-cpp/releases/download/2.1.0/rocketmq-client-cpp-2.1.0-bin-release-darwin.tar.gz tar -xzf rocketmq-client-cpp-2.1.0-bin-release-darwin.tar.gz cd rocketmq-client-cpp mkdir /usr/local/include/rocketmq cp include/ /usr/local/include/rocketmq cp lib/ /usr/local/lib install_name_tool -id "@rpath/librocketmq.dylib" /usr/local/lib/librocketmq.dylib

and if your system is linux or other,you need download corresponding system files,linux:rocketmq-client-cpp-2.1.0-centos7.x86_64.rpm wget https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.0/rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm sudo rpm -ivh rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm Replace the 2.0.0 version in the above command with 2.1.0