On 01/16/2014 02:04 AM, Xiong Zou wrote:
Hi All,

I am experimenting qpid Pub-Sub pattern, referring to
examples/old_api/pub-sub sample codes. My qpid version is 0.20.

I would strongly advise you to switch to the qpid::messaging API[1] if at all possible. The qpid::client API has been removed in the latest versions of Qpid. Further comments on the code inline.

[1] http://qpid.apache.org/releases/qpid-0.24/programming/book/index.html

Sometimes I received warning message like below sample: when I stop my
binary:
2014-01-16 08:58:33 [Client] warning Session was not closed cleanly:
anonymous.fa805922-8f1b-4e67-9710-a3da31e9bfc8
[...]
         void CListener::stop()
         {
                 //No need to cancel subscriptions with
m_subscriptions.stop().
                 //for(unsigned int i; i < m_vecQueueUIDs.size(); i++)
                 //{
                 //      if(!m_vecQueueUIDs[i].empty())
                 //              m_subscriptions.cancel(m_vecQueueUIDs[i]);
                 //}
                 // stop the spawned thread
                 m_subscriptions.stop();

Add

   m_subscriptions.wait();

to wait for the thread to actually exit here. I would personally advise you to start your own thread and call m_subscriptions.run() on it, as the start()/stop() method doesn't handle exceptions occurring on dispatch well.

         }

};

[...]

IPC::CQPIDPubSubAdaptor::~CQPIDPubSubAdaptor()
{
         INFO << "start to clear up QPIDPubSubAdaptor" << ENDL;
         if(m_pConListner)
         {
                 CListener* pListner = (CListener*)m_pConListner;
                 pListner->stop();
                 //delete pListner;     //cannot delete listner, will cause
~Mutex() to signal
                 m_pConListner = NULL;
         }


Do an explicit m_session.close() here as well. If you want to be extr safe to an explicit m_session.sync() before that to ensure all inflight operations are complete.

         m_connection.close();

         if(m_pSession)
         {
                 delete m_pSession;
                 m_pSession = NULL;
         }

         if(m_pHelpQueue)
         {
                 delete m_pHelpQueue;
                 m_pHelpQueue = NULL;
         }
}


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

Reply via email to