Hi,

I have been creating a producer client using qpid 0.14 (running 64bit CENTOS 6.2) and I have encountered some unexpected behavior that I wondered if someone could shed some light on.

The code shown below connects to a broker and then sends messages on a exchange topic called foo with a subject of bar (this was commented out to simplify the test) . If the broker is not up then everything works find and the client will loop around until the broker becomes available and it can then start sending its messages.

But if the client is connected to the broker and I kill the broker (to simulate a broker crash) and then restart the broker several minutes later, the client NEVER reconnects. All I see is a "warning connection closed message" being reported by the client and the output from my loop every 10 seconds.

If I attach gdb the connection thread gives me the following stack trace

(gdb) where
#0  0x0000003c7b8ab15d in nanosleep () from /lib64/libc.so.6
#1  0x0000003c7b8aafd0 in sleep () from /lib64/libc.so.6
#2 0x00000000004012d6 in main (argc=1, argv=0x7fff9d918a78) at producer.cpp:38
(gdb) info threads
2 Thread 0x7f73bd18a700 (LWP 11947) 0x0000003c7b8e62c3 in epoll_wait () from /lib64/libc.so.6 * 1 Thread 0x7f73bd9e67a0 (LWP 11946) 0x0000003c7b8ab15d in nanosleep () from /lib64/libc.so.6
(gdb) thread 2
[Switching to thread 2 (Thread 0x7f73bd18a700 (LWP 11947))]#0 0x0000003c7b8e62c3 in epoll_wait ()
   from /lib64/libc.so.6
(gdb) where
#0  0x0000003c7b8e62c3 in epoll_wait () from /lib64/libc.so.6
#1 0x0000003ba3b49c2a in qpid::sys::Poller::wait(qpid::sys::Duration) () from /usr/lib64/libqpidcommon.so.6 #2 0x0000003ba3b4a187 in qpid::sys::Poller::run() () from /usr/lib64/libqpidcommon.so.6
#3  0x0000003ba3b4236a in ?? () from /usr/lib64/libqpidcommon.so.6
#4  0x0000003c7c4077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003c7b8e5ccd in clone () from /lib64/libc.so.6
(gdb)


I can fix the code by using the isOpen() method on the Connection class as the test for the while loop, but this doesn't seem correct; especially as I have enabled the reconnect functionality

#include <string>
#include <cstdlib>
#include <iostream>

#include <qpid/Exception.h>
#include <qpid/messaging/Session.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Connection.h>

/*
 *
 */
int main(int argc, char** argv) {

   while(true){
        try{
          std::string broker = "127.0.0.1:5673";
std::string options = "{reconnect:true,reconnect-interval:5,reconnect-timeout:30}"; qpid::messaging::Connection connection = qpid::messaging::Connection(broker,options);
          connection.open();
          qpid::messaging::Session session = connection.createSession();
          qpid::messaging::Sender sender = session.createSender("foo");
          while(true){
             //qpid::messaging::Message message;
             //message.setContent("TEST MESSAGE");
             //message.setSubject("bar");
             //sender.send(message,true);
             std::cout << "Doing work" << std::endl;
             sleep(10);
          }
        }
        catch(const qpid::messaging::MessagingException& me){
std::cout << "Caught MessagingException : " << me.what() << std::endl;
        }
        catch(const qpid::ConnectionException& ce){
std::cout << "Caught ConnectionException : " << ce.what() << std::endl;
        }
        catch (const qpid::Exception& e){
            std::cout << "Caught Exception : " << e.what() << std::endl;
        }
        sleep(5);
   }
   return 0;
}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to