activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Crable <>
Subject Re: gracefully restarting a c++/openwire session
Date Sun, 14 Oct 2007 20:12:47 GMT

Thanks, I just wrapped the whole CMS broker/sessions in another class to
handle it.  However, I noticed that if I close the producer/consumer before
I close the broker/session it'll throw an exception.  I think it was
complaining about it already being closed.  Anyway, I've got something
working fairly well now its just a little hairy as to what needs to be
closed/stopped before deleting sessions & brokers.  For others listening,
the order of destruction/shutdown that works for me is:

    for(iSession = m_queues.begin();
        iSession != m_queues.end(); iSession++){
    for(iSession = m_topics.begin();
        iSession != m_topics.end(); iSession++){
    if (m_session){
        delete m_session;
        m_session = NULL;
    if (m_connection){
        delete m_connection;
        m_connection = NULL;

>> Where session->close() does: <<

        //m_consumer->close(); << This fails later when broker/session
        delete m_consumer;
        m_consumer = NULL;
        //m_producer->close(); << Same thing here, just left them open
        delete m_producer;
        m_producer = NULL;
        delete m_destination;
        m_destination = NULL;

Tim Bish wrote:
> You must destroy the connection and create a new connection / session 
> etc.  We don't have a fail over transport but you are welcome to write 
> one and donate it  :)
> Fred Crable wrote:
>> Is there a best practice for gracefully restarting an openwire/c++
>> consumer
>> or producer session.  I'm hesitant to destroy and rebuild the connection,
>> session, and all of the consumers when I get an connection exception in
>> my
>> exception listener.  I can't use failover:tcp: in an openwire broker uri. 
>> Do I really have to unwind/destroy all of my consumer handles?  I've
>> looked
>> all over for some methods or hints but I don't see any examples of
>> reconnecting after a client connection failure.
>> Thanks,
>> Fred

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

View raw message