ActiveMQ-cpp client abnormal application exit problem, activemq Client

Source: Internet
Author: User

ActiveMQ-cpp client abnormal application exit problem, activemq Client

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 lies in the exception handling of the custom Concumer class, and CALLS exit (1 );

//SimpleAsyncConsumer. cpp [1]

Void SimpleAsyncConsumer: onException (const CMSException & ex AMQCPP_UNUSED) {  Printf ("CMS Exception occurred.Shutting down client. \ n ");  Exit (1 ); } After exit (1) is commented out, the problem is solved and the client will no longer exit unexpectedly. However, during the network disconnection test, the client cannot detect that the connection to the server is disconnected. Status variable.

Void SimpleAsyncConsumer: onException (const CMSException & ex AMQCPP_UNUSED) {  Printf ("CMS Exception occurred.Shutting down client. \ n ");  Connflag = false; }The upper-layer caller detects the connection status in real time, releases resources when false is detected, and waits for a reconnection.


[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.