You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by joost <jo...@task24.nl> on 2010/12/08 14:17:55 UTC

ActiveMQ-cpp: Check if ActiveMQ server is running

I use ActiveMQ-cpp to make a connection with an AcitveMQ server. The
CMSConnection is started with: 

        // Create a ConnectionFactory 
        auto_ptr<ConnectionFactory> connectionFactory( 
            ConnectionFactory::createCMSConnectionFactory( brokerURI ) ); 

        // Create a Connection 
        connection = connectionFactory->createConnection(); 
        connection->start(); 

This works fine if the ActiveMQ server is running, but when the user forgets
to start the ActiveMQ server before starting my application, the application
hangs in the function CMSConnection::start(). Is there a way to check if a
connection can be made with the ActiveMQ server before starting the
connection, or maybe a timeout on CMSConnection->start() is possible? 

Joost 

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-cpp-Check-if-ActiveMQ-server-is-running-tp3078173p3078173.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQ-cpp: Check if ActiveMQ server is running

Posted by joost <jo...@task24.nl>.
Changing the failover settings (or just disabling failover) solved the
problem.
Thanks!

Joost

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-cpp-Check-if-ActiveMQ-server-is-running-tp3078173p3078288.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQ-cpp: Check if ActiveMQ server is running

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2010-12-08 at 05:17 -0800, joost wrote:
> I use ActiveMQ-cpp to make a connection with an AcitveMQ server. The
> CMSConnection is started with: 
> 
>         // Create a ConnectionFactory 
>         auto_ptr<ConnectionFactory> connectionFactory( 
>             ConnectionFactory::createCMSConnectionFactory( brokerURI ) ); 
> 
>         // Create a Connection 
>         connection = connectionFactory->createConnection(); 
>         connection->start(); 
> 
> This works fine if the ActiveMQ server is running, but when the user forgets
> to start the ActiveMQ server before starting my application, the application
> hangs in the function CMSConnection::start(). Is there a way to check if a
> connection can be made with the ActiveMQ server before starting the
> connection, or maybe a timeout on CMSConnection->start() is possible? 
> 
> Joost 
> 

The failover transport is probably in use so the hang at start is normal
as the client is waiting for a broker to connect to before proceeding.
You can play around with the failover transport options if you really
want it to fail.  See: http://activemq.apache.org/cms/configuring.html

Regards

-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/