qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Ross <tr...@redhat.com>
Subject C++ Client Question
Date Tue, 02 Dec 2008 23:12:39 GMT
I have a usage question about the C++ client api that is not addressed 
by the examples.

My application needs to maintain a connection to the broker.  If the 
connection cannot be established, the application retries based on an 
increasing interval.  If the established connection is dropped, the 
application attempts to reconnect.

This code fragment is the body (run method) of a connection thread (with 
non-pertinent details removed for simplicity):

    Connection connection;
    Session session;
    SubscriptionManager *subscriptions;


    while (true) {
        try {
            session = connection.newSession(queueName-string);
            subscriptions = new client::SubscriptionManager(session);
            subscriptions->subscribe(listener, queueName-string, 
            try {
            } catch (exception) {}

            delete subscriptions;
            subscriptions = 0;
        } catch (exception &e) {
            // adjust sleep delay


1) Is it ok to reuse the connection object (i.e. open => close => open)?
2) Is it ok to reuse the session object?  Note that I never call 
session.close or explicitly invoke its destructor.
3) Is there anything wrong or inadvisable with the way I've done this?



View raw message