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

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

I changed the simple producer example so that the broker URI is:
----------------------------------------
    std::string brokerURI =
        "failover:(tcp://127.0.0.1:61616"
        "?initialReconnectDelay=10"
        "&maxReconnectDelay=100"
        "&useExponentialBackOff=false"
        "&maxReconnectAttempts=1"
        "&startupMaxReconnectAttempts=1"
        "&timeout=100"
        ")";
----------------------------------------


And I added output to show me the brokerURI and it is as I expected:
----------------------------------------
Broker URI:
failover:(tcp://127.0.0.1:61616?initialReconnectDelay=10&maxReconnectDelay=100&useExponentialBackOff=false&maxReconnectAttempts=1&startupMaxReconnectAttempts=1&timeout=100)
----------------------------------------

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

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

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

        connection->start();

    } catch( CMSException& e ) {
        e.printStackTrace();
        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: 
http://activemq.2283324.n4.nabble.com/Do-activemq-cpp-connection-questions-tp4119766p4121275.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to