sikey647 opened a new issue #335:
URL: https://github.com/apache/rocketmq-client-cpp/issues/335


   ## 1、issue description
   * There is a segment error when I execute the following code. it seems that 
it occurred when executed shutdown().
   ```c++
   #include <iostream>
   #include <string>
   #include <thread>
   #include "rocketmq/DefaultMQPushConsumer.h"
   
   using namespace rocketmq;
   
   class ProcessMsgListener : public MessageListenerConcurrently {
   public:
       ProcessMsgListener() {}
       virtual ~ProcessMsgListener() {}
   
       virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& 
msgs) {
           for (size_t i = 0; i < msgs.size(); ++i) {
               std::cout << "msg id: " << msgs[i].getMsgId() << ", queue id: " 
<< msgs[i].getQueueId() << ", msg body: "<<  msgs[i].getBody() << std::endl;
           }
           return CONSUME_SUCCESS;
       }
   };
   
   int main() {
       // ----------- 1、初始化 ---------------
       // 1). 初始化配置参数
       std::string groupName = "test_consumer_group";
       std::string namesrvAddr = "172.29.240.23:6060";
       int connectTimeout = 400;
       int tryLockTimeout = 1000;
       int threadCount = 1;
       // 0: async; 1: sync
       int syncFlag = 1;
       // 0: BROADCASTING; 1: CLUSTERING
       int modelFlag = 1;
       // 消息参数
       std::string topic = "test_topic";
       std::string tag = "*";
   
       // 2). 初始化 consumer
       DefaultMQPushConsumer consumer(groupName);
       consumer.setInstanceName(groupName);
       consumer.setNamesrvAddr(namesrvAddr);
       consumer.setTcpTransportConnectTimeout(connectTimeout);
       consumer.setTcpTransportTryLockTimeout(tryLockTimeout);
       consumer.setConsumeThreadCount(threadCount);
       consumer.setConsumeFromWhere(CONSUME_FROM_LAST_OFFSET);
       if (syncFlag)
           consumer.setAsyncPull(false);
       else
           consumer.setAsyncPull(true);
       if (modelFlag)
           consumer.setMessageModel(CLUSTERING);
       else
           consumer.setMessageModel(BROADCASTING);
   
       ProcessMsgListener msgListener;
       consumer.registerMessageListener(&msgListener);
       consumer.subscribe(topic, tag);
   
       // 3). 启动 consumer
       consumer.start();
       std::cout << "consume start!" << std::endl;
   
       // consumer 已开始工作,需要阻塞主进程
       //while (1)
       std::this_thread::sleep_for(std::chrono::seconds(10));
   
       // ---------- 3、结束 ----------
       consumer.shutdown();
       std::cout << "consume finish!" << std::endl;
       std::this_thread::sleep_for(std::chrono::seconds(3));
   
       return 0;
   }  
   ```
   * output:
     consume start!
     msg id: AC1DF0286BFA2196071D13AC8BD50000, queue id: 0, msg body: this is 
the test message!
     segmentation fault(core dump)
      
   ## 2、environment info
   * OS:  CentOS Linux release 7.5.1804 (Core)
   * client version:  rocketmq-client-cpp-2.1.0
   * RocketMQ version:   rocketmq-4.7.1


----------------------------------------------------------------
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:
[email protected]


Reply via email to