ActiveMQ-cpp client application exited abnormally

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.