apache / apache/rocketmq-client-python

A process is launched within the callback function, and an error occurs when attempting to send an MQ message within that process.

Offen
#147 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
305
Forks
98
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

i write a code like that:
```python
from multiprocessing import Process
from rocketmq.client import Producer, Message, PushConsumer, ConsumeStatus
import time
import json

def rmq_consumer():
consumer = PushConsumer('group_demo')
consumer.set_name_server_address('10.13.2.12:9876')
consumer.subscribe('start_or_end_detect', send_message, "*")
print(' [Consumer] Waiting for messages.')
consumer.start()
while True:
time.sleep(1)

def start_pro():
producer = Producer('test_producer')
producer.set_name_server_address('10.13.2.12:9876')
producer.start()
try:
event = {"aa": "vv", "bb": 33}
msg = Message("fireMsg")
ss = json.dumps(event).encode('utf-8')
msg.set_body(ss)
producer.send_sync(msg)

finally:
producer.shutdown()

def send_message():
i = Process(target=start_pro)
i.start()

return ConsumeStatus.CONSUME_SUCCESS

if __name__ == '__main__':
rmq_con = Process(target=rmq_consumer)
```
The code snippet "'**producer.send_sync(msg)**'"
throws an error
**"rocketmq.exceptions.ProducerSendSyncFailed: No route info of this topic: fireMsg,error:-1,in file rocketmq-client-cpp/src/producer/DefaultMQProducerImpl.cpp line:434"**

What could be the cause of this? My RocketMQ deployment is functioning normally.

**If I don't execute Process(target=start_pro) within the send_message method and instead directly include the contents of start_pro within send_message, the aforementioned error does not occur.**

Looking forward to your response. Thank you.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reproducing the example around rmq_consumer, send_message, start_pro, and producer.send_sync, comparing the direct callback path with the Process(target=start_pro) path. Trace the producer startup and topic route lookup in the Python client and its RocketMQ client dependency. Done means identifying why the child process receives no route info for fireMsg and documenting a verified cause or correction.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
distributed-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.