activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JRR <>
Subject Re: Do activemq-cpp connection questions.
Date Wed, 30 Nov 2011 00:20:11 GMT
Hello Tim,

I am playing with the simple producer and the fail over options. However, I
am not getting the results I expected and I'm hoping you can share some

I am using version 3.2.3 of the activemq-cpp library on a SuSE Linux

I changed the simple producer example so that the broker URI is:
    std::string brokerURI =

And I added output to show me the brokerURI and it is as I expected:
Broker URI:

I wanted to test the scenario when starting the producer when the broker
isn't running. With these setting, my expectation is that it would throw an
exception when the factory created the connection, and I would see the 
stack trace (as per the simple example).

However, what I found is that a connection object is created and returned
(even though the broker is not running), and then the code blocks at the
start() call that follows the connection create. I've confirmed this with

    // Create a Connection
        std::cout << "Connection before " << connection << "\n";
        connection = connectionFactory->createConnection();

        std::cout << "Connection after " << connection << "\n";
        std::cout << "Connection done. Starting it\n";


    } catch( CMSException& e ) {
        throw e;
    std::cout << "Connection start done. Creating Session\n";

What is the corrrect way to do this? What I want is to use the failover
method, but I don't want to wait forever. If the producer cannot initially
connect, I'd like to eventually timeout and quit.

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message