You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/10/16 08:31:57 UTC

[GitHub] [rocketmq-client-python] tom0392 opened a new issue #99: How to use rockemq in multi-threaded scenarios properly and handle exceptions such as Namer Server Cluster and Broker Cluster restart

tom0392 opened a new issue #99:
URL: https://github.com/apache/rocketmq-client-python/issues/99


   ### Description of problem
   We send messages from the client to the MQ server at a certain interval by using multiple threads following the steps below:
   ```
   Producer
   from rocketmq.client import Producer, Message
   
   producer = Producer('PID-XXX')
   producer.set_name_server_address('127.0.0.1:9876')
   producer.start()
   
   msg = Message('YOUR-TOPIC')
   msg.set_keys('XXX')
   msg.set_tags('XXX')
   msg.set_body('XXXX')
   ret = producer.send_sync(msg)
   print(ret.status, ret.msg_id, ret.offset)
   producer.shutdown()
   ```
   When a restart of the MQ server including Namer Server Cluster and Broker Cluster causes the service to stop for a short time, the MQ client will report an error at first when sending a MQ message:
   
   > Throw an exception in the program as:
   >   File "/usr/lib/python2.7/site-packages/neutron_lbaas/drivers/bcslb/monitor/eslb_monitor.py", line 80, in push_message_to_rocketMQ_handler
   >     ret = producer.send_sync(msg)
   >   File "/usr/lib64/python2.7/site-packages/rocketmq/client.py", line 210, in send_sync
   >     ffi_check(dll.SendMessageSync(self._handle, msg, ctypes.pointer(c_result)))
   >   File "/usr/lib64/python2.7/site-packages/rocketmq/exceptions.py", line 44, in ffi_check
   >     raise exc_cls(msg)
   > ProducerSendSyncFailed: No route info of this topic: dawn-bcmq-performance-topic,error:-1,in file rocketmq-client-cpp/src/producer/DefaultMQProducerImpl.cpp line:418
   
   We think the reason for this error is that the Name server cannot be connected normally, which leads to no routing information. However, when the MQ server returns to normal after restart, the client will still keep reporting errors:
   
   > ProducerStartFailed: The producer group[] has been created before, specify another name please.,error:-1,in file rocketmq-client-cpp/src/producer/DefaultMQProducerImpl.cpp line:79
   
   ### Problem analysis
   When the MQ Server is stopped, the first thread has been in an abnormal state and cannot go to the following shutdown step normally:
   `producer.shutdown()
   `
   Then, the program starts the second thread to send messages, and calling producer.start() results in an error:
   
   > The producer group[ ] has been created before, specify another name please.
   
   As long as the first thread that has the problem at the beginning cannot shutdown producer normally, all subsequent new threads will cause the same error as the second thread when run to _producer.start()_. Even when the MQ server restarts and returns to normal, the client will continue to report that same error.
   
   ### suggestion
   
   1. First suggestion
   
   When the producer sends a message successfully, the program will return SendStatus.OK=0 to the ret variable. So we think when the producer fails to send a message,  the program should return an error code to the ret accordingly and not to throw an exception to stop the whole program.
   
   2. Second suggestion
   
   Is there a recommended  usage steps of producer for rocketmq's multi-thread usage scenarios?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-client-python] ifplusor commented on issue #99: How to use rockemq in multi-threaded scenarios properly and handle exceptions such as Namer Server Cluster and Broker Cluster restart

Posted by GitBox <gi...@apache.org>.
ifplusor commented on issue #99:
URL: https://github.com/apache/rocketmq-client-python/issues/99#issuecomment-711457934


   When send failed, don't shut down, instead of cache the message to retry or report an error.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-client-python] vongosling closed issue #99: How to use rockemq in multi-threaded scenarios properly and handle exceptions such as Namer Server Cluster and Broker Cluster restart

Posted by GitBox <gi...@apache.org>.
vongosling closed issue #99:
URL: https://github.com/apache/rocketmq-client-python/issues/99


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org