zhangyulu opened a new issue #164: Nothing happened to start a consumer even if 
I setup a non-exist nameserver address
URL: https://github.com/apache/rocketmq-client-cpp/issues/164
 
 
   I wrote a simple PushConsumer based on example/PushConsumer.cpp. I typed  a 
wrong nameserver port(nameserver listen on port 9876 as default), but nothing 
happened, no any exceptions, and I checked the DefaultMQPushConsumer::start() 
is a void method, so how should I detect this kind of errors? Thanks
   The code shows below:
   
   ```
   #include <stdlib.h>
   #include <string.h>
   
   #include <chrono>
   #include <iomanip>
   #include <iostream>
   #include <map>
   #include <string>
   #include <vector>
   #include <thread>
   
   #include "DefaultMQPushConsumer.h"
   
   using namespace rocketmq;
   using namespace std;
   
   class MyMsgListener : public MessageListenerConcurrently {
    public:
     MyMsgListener() {}
     virtual ~MyMsgListener() {}
   
     virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& 
msgs) {
       for (auto& msg : msgs) {
         cout << "msg body: "<<  msg.getBody() << endl;
       }
       return CONSUME_SUCCESS;
     }
   };
   
   int main(int argc, char* argv[]) {
     DefaultMQPushConsumer consumer("zyl_consumer_group");
     consumer.setNamesrvAddr("192.168.1.102:9875");
   
     consumer.setConsumeThreadCount(1);
     consumer.setConsumeFromWhere(CONSUME_FROM_LAST_OFFSET);
   
     consumer.subscribe("test-topic", "*");
     //consumer.setTcpTransportTryLockTimeout(1000);
     //consumer.setTcpTransportConnectTimeout(400);
   
     MyMsgListener msglistener;
     consumer.registerMessageListener(&msglistener);
   
     try {
       consumer.start();
     } catch (MQClientException& e) {
       cout << e << endl;
       return -1;
     }
   
     while (1) {
         std::this_thread::sleep_for(std::chrono::seconds(1));
     }
     consumer.shutdown();
     return 0;
   }
   ```
   

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to