ActiveMQ-cpp client application exited abnormally
The author uses ActiveMQ as the server for message distribution in the system. The Java Web program reads the database real-time records as the Producer, and the receiving end is the client program developed by C ++ Builder. It is resident in the lower right corner of the client, the pop-up window displays real-time messages. During the test, it is found that when the client is disconnected (the network cable is unplugged) or the server is restarted, the client will exit directly, and windows does not report a program crash, which is hard to understand. The Debug debugging code finds that the problem occurs when the custom Concumer class exception is handled, the exit (1) is called; // SimpleAsyncConsumer. cpp [1] void SimpleAsyncConsumer: onException (const CMSException & ex AMQCPP_UNUSED) {printf ("CMS Exception occurred. shutting down client. \ n "); exit (1) ;}comment out exit (1) and solve the problem. The client will no longer exit unexpectedly. However, during the network disconnection test, the client cannot detect the state of being disconnected from the server. I use the SimpleAsyncConsumer class to add status variables. Void SimpleAsyncConsumer: onException (const CMSException & ex AMQCPP_UNUSED) {printf ("CMS Exception occurred. shutting down client. \ n "); connflag = false;} the upper-layer calling program detects the connection status in real time. If it detects false, the resource is released and the connection is reconnected. [1] reference: http://blog.sina.com.cn/s/blog_a459dcf501017ooh.html shaoming blog ActiveMQ complete C ++ client example (source code), the use of client concumer see this article.