You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by mrdiesel <mr...@gmail.com> on 2011/11/16 21:02:00 UTC

The Decaf Threading API is in a Shutdown State. Exception

        try{
             if( session != NULL ) session->close();
            if( connection != NULL ) connection->close();
        }catch (CMSException& e) {e.printStackTrace();}

I m getting an exception as follows:

The Decaf Threading API is in a Shutdown State.
        FILE: decaf/lang/Thread.cpp, LINE: 616
        FILE: activemq/core/ActiveMQSession.cpp, LINE: 172

Why is this happening?

how can i avoid this? this is causing problems when i try to get more
messages. 

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077689.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 13:30 -0800, mrdiesel wrote:
> I m getting the same segmentation fault error.
> 
> I moved the init and shutdown statements outside the for loop.
> 
> 0test
> 1test
> 2test
> 3test
> Segmentation fault (core dumped)
> 

There are several good examples in the unit and integration tests you
can look at.  You haven't indicated what compiler and OS you are using
or what version of the lib so I can't speak to any know issues.  You
also appear to have a memory leak in the runConsumer method since you
aren't deleting the message pointer that receive returns.  

> is there a sample, synchronous c++ client i can look? I m really not getting
> why this is happening? 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077949.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 14:03 -0800, mrdiesel wrote:
> Where can i find unit tests or other examples? rather than the ones come with
> package?
> 

Look in the folders named, "test" and "test-integration"

The integration tests require a running broker and provide many exmaples
of using the CMS API.

> Thanks.
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4078091.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
Where can i find unit tests or other examples? rather than the ones come with
package?

Thanks.

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4078091.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
when i m debugging, it just hangs.

8test
[Thread -188621920 (LWP 5666) exited]
[Thread -146584672 (LWP 5657) exited]
[Thread -178132064 (LWP 5663) exited]
[Thread -167642208 (LWP 5662) exited]
[Thread -157152352 (LWP 5659) exited]
[New Thread -146584672 (LWP 5670)]
[New Thread -157152352 (LWP 5671)]
[New Thread -167642208 (LWP 5673)]
[New Thread -178132064 (LWP 5676)]
[New Thread -188621920 (LWP 5678)]
9test


never finishes.

I m looking at JMX, connection is open, not closed or closing.

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077976.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
I m getting the same segmentation fault error.

I moved the init and shutdown statements outside the for loop.

0test
1test
2test
3test
Segmentation fault (core dumped)

is there a sample, synchronous c++ client i can look? I m really not getting
why this is happening? 

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077949.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 12:53 -0800, mrdiesel wrote:
> I took exactly the same code from examples, but instead of asynchronous, i
> want synchronous client. So all i changed was remove tge listeners and
> return the message to runConsumer method.
> 

Try calling init and shutdown on the library outside the for loop

> I keep getting segmentation fault. 
> 
> Can you advise?
> 
> Below is the code I m running:
> #include <decaf/lang/Thread.h>
> #include <decaf/lang/Runnable.h>
> #include <decaf/util/concurrent/CountDownLatch.h>
> #include <activemq/core/ActiveMQConnectionFactory.h>
> #include <activemq/core/ActiveMQConnection.h>
> #include <activemq/transport/DefaultTransportListener.h>
> #include <activemq/library/ActiveMQCPP.h>
> #include <decaf/lang/Integer.h>
> #include <activemq/util/Config.h>
> #include <decaf/util/Date.h>
> #include <cms/Connection.h>
> #include <cms/Session.h>
> #include <cms/TextMessage.h>
> #include <cms/BytesMessage.h>
> #include <cms/MapMessage.h>
> #include <cms/ExceptionListener.h>
> #include <cms/MessageListener.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <iostream>
> 
> using namespace activemq;
> using namespace activemq::core;
> using namespace activemq::transport;
> using namespace decaf::lang;
> using namespace decaf::util;
> using namespace decaf::util::concurrent;
> using namespace cms;
> using namespace std;
> 
> ////////////////////////////////////////////////////////////////////////////////
> class YConsumer{
> private:
> 
>     Connection* connection;
>     Session* session;
>     Destination* destination;
>     MessageConsumer* consumer;
>     bool useTopic;
>     std::string brokerURI;
>     std::string destURI;
>     bool clientAck;
> 
> public:
> 
>      YConsumer( const std::string& brokerURI,
>                          const std::string& destURI,
>                          bool useTopic = false,
>                          bool clientAck = false ) :
>         connection(NULL),
>         session(NULL),
>         destination(NULL),
>         consumer(NULL),
>         useTopic(useTopic),
>         brokerURI(brokerURI),
>         destURI(destURI),
>         clientAck(clientAck) {
>     }
> 
> 
>     virtual ~YConsumer() throw() {
>         this->cleanup();
>     }
> 
>     void close() {
>         this->cleanup();
>     }
> 
>     string runConsumer() {
> 
>         try {
>          
>             auto_ptr<ConnectionFactory>
> connectionFactory(ConnectionFactory::createCMSConnectionFactory( brokerURI )
> );
>  
>             connection = connectionFactory->createConnection();
>  
>             connection->start();
> 
>  
>             connection->start();
>  
> 
> 	    if( clientAck ) {
>                 session = connection->createSession(
> Session::CLIENT_ACKNOWLEDGE );
>             } else {
>                 session = connection->createSession(
> Session::AUTO_ACKNOWLEDGE );
>             }
>  
>             if( useTopic ) {
>                 destination = session->createTopic( destURI );
>             } else {
>                 destination = session->createQueue( destURI );
>             }
>  
>             consumer = session->createConsumer( destination );
>  
> 	    Message* message = consumer->receive();
>  
> 	    TextMessage* textMessage = dynamic_cast<TextMessage* >( message );
>  	
> 	    string text = "";
>             
> 
> 	    if( textMessage != NULL ) {
>                 text = textMessage->getText();
>             } else {
>                 text = "NOT A TEXTMESSAGE!";
>             }
>      
> 	    //std::cout<<text.c_str()&lt;&lt;std::endl;
>             //delete message;
> 	    //delete textMessage;
>      
> 		return text.c_str();
>         } catch (CMSException&amp; e) {
>             e.printStackTrace();
>         }
>     }
> 
> private:
> 
>     void cleanup(){
> 
>         //*************************************************
>         // Always close destination, consumers and producers before
>         // you destroy their sessions and connection.
>         //*************************************************
>  
>         // Destroy resources.
>         try{
>             if( destination != NULL ) delete destination;
>         }catch (CMSException&amp; e) {e.printStackTrace();}
>         destination = NULL;
>  
>         try{
>             if( consumer != NULL ) delete consumer;
>         }catch (CMSException&amp; e) {e.printStackTrace();}
>         consumer = NULL;
>  
>         // Close open resources.
>         try{
>   
>             if( session != NULL ) session->close();
>             if( connection != NULL ) connection->close();
>         }catch (CMSException& e) {e.printStackTrace();}
>  
>         // Now Destroy them
>         try{
>             if( session != NULL ) delete session;
>         }catch (CMSException& e) {e.printStackTrace();}
>         session = NULL;
>  
>         try{
>             if( connection != NULL ) delete connection;
>         }catch (CMSException& e) {e.printStackTrace();}
>         connection = NULL;
>  
>     }
> };
> 
> ////////////////////////////////////////////////////////////////////////////////
> int main(int argc AMQCPP_UNUSED, char* argv[] AMQCPP_UNUSED) {
>  for(int i=0; i< 100;i++){
>     activemq::library::ActiveMQCPP::initializeLibrary();
>  
>     std::string brokerURI =
> "failover:(tcp://127.0.0.1:61613?wireFormat=stomp)";
>         
>     std::string destURI = "TEST.Prototype";  
>  
>     bool useTopics = false;
>  
>     bool clientAck = false;
>  
>     YConsumer consumer( brokerURI, destURI, useTopics, clientAck );
>   
>     string response = consumer.runConsumer();
>    
>     std::cout<< response<<std::endl;
>   
>     consumer.close();
>  
>     //activemq::library::ActiveMQCPP::shutdownLibrary();
> } 
> }
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077852.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

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




Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
OK It turns out that the version I was using was sick. I used v3.4 and no
problems.

Thanks Tim.

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4081893.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
Hi Tim,

yes, i m aware that can be done but i m not quite sure, if i can do that
with c++. you are saying, have your program keep the connection open as long
as the program is open and for each get request, i ll ask the consumer to
receive one. rigth?

any samples on this?

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4080856.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 15:34 -0800, mrdiesel wrote:
> I got the segmentation fault again. but i was able to process 4000 messages.
> before it was crapping right away. there must be a leak somewhere else?
> right?
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4078311.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Hard to say, still don't know what version of the library you have, make
sure you have the latest v3.4.0.  The only way to debug is to capture a
backtrace of all the threads at the time of the segfault.

You know you don't need to create a connection / session etc each time
you want to consume a message right?  You can just create a consumer and
call receive when you want a message.

Regards

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




Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
I got the segmentation fault again. but i was able to process 4000 messages.
before it was crapping right away. there must be a leak somewhere else?
right?

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4078311.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
wow. that did it actually. it works now and no segmentation fault.

Thanks man!!!. 

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4078288.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 12:53 -0800, mrdiesel wrote:
> I took exactly the same code from examples, but instead of asynchronous, i
> want synchronous client. So all i changed was remove tge listeners and
> return the message to runConsumer method.
> 
> I keep getting segmentation fault. 
> 
> Can you advise?
> 

You can also simplify your cleanup method as follows:

    void cleanup() {
        if (connection != NULL) {
            connection->close();
        }
        delete destination;
        destination = NULL;
        delete consumer;
        consumer = NULL;
        delete session;
        session = NULL;
        delete connection;
        connection = NULL;
    }

Regards
Tim.

> Below is the code I m running:
> #include <decaf/lang/Thread.h>
> #include <decaf/lang/Runnable.h>
> #include <decaf/util/concurrent/CountDownLatch.h>
> #include <activemq/core/ActiveMQConnectionFactory.h>
> #include <activemq/core/ActiveMQConnection.h>
> #include <activemq/transport/DefaultTransportListener.h>
> #include <activemq/library/ActiveMQCPP.h>
> #include <decaf/lang/Integer.h>
> #include <activemq/util/Config.h>
> #include <decaf/util/Date.h>
> #include <cms/Connection.h>
> #include <cms/Session.h>
> #include <cms/TextMessage.h>
> #include <cms/BytesMessage.h>
> #include <cms/MapMessage.h>
> #include <cms/ExceptionListener.h>
> #include <cms/MessageListener.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <iostream>
> 
> using namespace activemq;
> using namespace activemq::core;
> using namespace activemq::transport;
> using namespace decaf::lang;
> using namespace decaf::util;
> using namespace decaf::util::concurrent;
> using namespace cms;
> using namespace std;
> 
> ////////////////////////////////////////////////////////////////////////////////
> class YConsumer{
> private:
> 
>     Connection* connection;
>     Session* session;
>     Destination* destination;
>     MessageConsumer* consumer;
>     bool useTopic;
>     std::string brokerURI;
>     std::string destURI;
>     bool clientAck;
> 
> public:
> 
>      YConsumer( const std::string& brokerURI,
>                          const std::string& destURI,
>                          bool useTopic = false,
>                          bool clientAck = false ) :
>         connection(NULL),
>         session(NULL),
>         destination(NULL),
>         consumer(NULL),
>         useTopic(useTopic),
>         brokerURI(brokerURI),
>         destURI(destURI),
>         clientAck(clientAck) {
>     }
> 
> 
>     virtual ~YConsumer() throw() {
>         this->cleanup();
>     }
> 
>     void close() {
>         this->cleanup();
>     }
> 
>     string runConsumer() {
> 
>         try {
>          
>             auto_ptr<ConnectionFactory>
> connectionFactory(ConnectionFactory::createCMSConnectionFactory( brokerURI )
> );
>  
>             connection = connectionFactory->createConnection();
>  
>             connection->start();
> 
>  
>             connection->start();
>  
> 
> 	    if( clientAck ) {
>                 session = connection->createSession(
> Session::CLIENT_ACKNOWLEDGE );
>             } else {
>                 session = connection->createSession(
> Session::AUTO_ACKNOWLEDGE );
>             }
>  
>             if( useTopic ) {
>                 destination = session->createTopic( destURI );
>             } else {
>                 destination = session->createQueue( destURI );
>             }
>  
>             consumer = session->createConsumer( destination );
>  
> 	    Message* message = consumer->receive();
>  
> 	    TextMessage* textMessage = dynamic_cast<TextMessage* >( message );
>  	
> 	    string text = "";
>             
> 
> 	    if( textMessage != NULL ) {
>                 text = textMessage->getText();
>             } else {
>                 text = "NOT A TEXTMESSAGE!";
>             }
>      
> 	    //std::cout<<text.c_str()&lt;&lt;std::endl;
>             //delete message;
> 	    //delete textMessage;
>      
> 		return text.c_str();
>         } catch (CMSException&amp; e) {
>             e.printStackTrace();
>         }
>     }
> 
> private:
> 
>     void cleanup(){
> 
>         //*************************************************
>         // Always close destination, consumers and producers before
>         // you destroy their sessions and connection.
>         //*************************************************
>  
>         // Destroy resources.
>         try{
>             if( destination != NULL ) delete destination;
>         }catch (CMSException&amp; e) {e.printStackTrace();}
>         destination = NULL;
>  
>         try{
>             if( consumer != NULL ) delete consumer;
>         }catch (CMSException&amp; e) {e.printStackTrace();}
>         consumer = NULL;
>  
>         // Close open resources.
>         try{
>   
>             if( session != NULL ) session->close();
>             if( connection != NULL ) connection->close();
>         }catch (CMSException& e) {e.printStackTrace();}
>  
>         // Now Destroy them
>         try{
>             if( session != NULL ) delete session;
>         }catch (CMSException& e) {e.printStackTrace();}
>         session = NULL;
>  
>         try{
>             if( connection != NULL ) delete connection;
>         }catch (CMSException& e) {e.printStackTrace();}
>         connection = NULL;
>  
>     }
> };
> 
> ////////////////////////////////////////////////////////////////////////////////
> int main(int argc AMQCPP_UNUSED, char* argv[] AMQCPP_UNUSED) {
>  for(int i=0; i< 100;i++){
>     activemq::library::ActiveMQCPP::initializeLibrary();
>  
>     std::string brokerURI =
> "failover:(tcp://127.0.0.1:61613?wireFormat=stomp)";
>         
>     std::string destURI = "TEST.Prototype";  
>  
>     bool useTopics = false;
>  
>     bool clientAck = false;
>  
>     YConsumer consumer( brokerURI, destURI, useTopics, clientAck );
>   
>     string response = consumer.runConsumer();
>    
>     std::cout<< response<<std::endl;
>   
>     consumer.close();
>  
>     //activemq::library::ActiveMQCPP::shutdownLibrary();
> } 
> }
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077852.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

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




Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
I took exactly the same code from examples, but instead of asynchronous, i
want synchronous client. So all i changed was remove tge listeners and
return the message to runConsumer method.

I keep getting segmentation fault. 

Can you advise?

Below is the code I m running:
#include <decaf/lang/Thread.h>
#include <decaf/lang/Runnable.h>
#include <decaf/util/concurrent/CountDownLatch.h>
#include <activemq/core/ActiveMQConnectionFactory.h>
#include <activemq/core/ActiveMQConnection.h>
#include <activemq/transport/DefaultTransportListener.h>
#include <activemq/library/ActiveMQCPP.h>
#include <decaf/lang/Integer.h>
#include <activemq/util/Config.h>
#include <decaf/util/Date.h>
#include <cms/Connection.h>
#include <cms/Session.h>
#include <cms/TextMessage.h>
#include <cms/BytesMessage.h>
#include <cms/MapMessage.h>
#include <cms/ExceptionListener.h>
#include <cms/MessageListener.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace activemq;
using namespace activemq::core;
using namespace activemq::transport;
using namespace decaf::lang;
using namespace decaf::util;
using namespace decaf::util::concurrent;
using namespace cms;
using namespace std;

////////////////////////////////////////////////////////////////////////////////
class YConsumer{
private:

    Connection* connection;
    Session* session;
    Destination* destination;
    MessageConsumer* consumer;
    bool useTopic;
    std::string brokerURI;
    std::string destURI;
    bool clientAck;

public:

     YConsumer( const std::string& brokerURI,
                         const std::string& destURI,
                         bool useTopic = false,
                         bool clientAck = false ) :
        connection(NULL),
        session(NULL),
        destination(NULL),
        consumer(NULL),
        useTopic(useTopic),
        brokerURI(brokerURI),
        destURI(destURI),
        clientAck(clientAck) {
    }


    virtual ~YConsumer() throw() {
        this->cleanup();
    }

    void close() {
        this->cleanup();
    }

    string runConsumer() {

        try {
         
            auto_ptr<ConnectionFactory>
connectionFactory(ConnectionFactory::createCMSConnectionFactory( brokerURI )
);
 
            connection = connectionFactory->createConnection();
 
            connection->start();

 
            connection->start();
 
 
	    if( clientAck ) {
                session = connection->createSession(
Session::CLIENT_ACKNOWLEDGE );
            } else {
                session = connection->createSession(
Session::AUTO_ACKNOWLEDGE );
            }
 
            if( useTopic ) {
                destination = session->createTopic( destURI );
            } else {
                destination = session->createQueue( destURI );
            }
 
            consumer = session->createConsumer( destination );
 
	    Message* message = consumer->receive();
 
	    TextMessage* textMessage = dynamic_cast<TextMessage* >( message );
 	
	    string text = "";
            

	    if( textMessage != NULL ) {
                text = textMessage->getText();
            } else {
                text = "NOT A TEXTMESSAGE!";
            }
     
	    //std::cout<<text.c_str()&lt;&lt;std::endl;
            //delete message;
	    //delete textMessage;
     
		return text.c_str();
        } catch (CMSException&amp; e) {
            e.printStackTrace();
        }
    }

private:

    void cleanup(){

        //*************************************************
        // Always close destination, consumers and producers before
        // you destroy their sessions and connection.
        //*************************************************
 
        // Destroy resources.
        try{
            if( destination != NULL ) delete destination;
        }catch (CMSException&amp; e) {e.printStackTrace();}
        destination = NULL;
 
        try{
            if( consumer != NULL ) delete consumer;
        }catch (CMSException&amp; e) {e.printStackTrace();}
        consumer = NULL;
 
        // Close open resources.
        try{
  
            if( session != NULL ) session->close();
            if( connection != NULL ) connection->close();
        }catch (CMSException& e) {e.printStackTrace();}
 
        // Now Destroy them
        try{
            if( session != NULL ) delete session;
        }catch (CMSException& e) {e.printStackTrace();}
        session = NULL;
 
        try{
            if( connection != NULL ) delete connection;
        }catch (CMSException& e) {e.printStackTrace();}
        connection = NULL;
 
    }
};

////////////////////////////////////////////////////////////////////////////////
int main(int argc AMQCPP_UNUSED, char* argv[] AMQCPP_UNUSED) {
 for(int i=0; i< 100;i++){
    activemq::library::ActiveMQCPP::initializeLibrary();
 
    std::string brokerURI =
"failover:(tcp://127.0.0.1:61613?wireFormat=stomp)";
        
    std::string destURI = "TEST.Prototype";  
 
    bool useTopics = false;
 
    bool clientAck = false;
 
    YConsumer consumer( brokerURI, destURI, useTopics, clientAck );
  
    string response = consumer.runConsumer();
   
    std::cout<< response<<std::endl;
  
    consumer.close();
 
    //activemq::library::ActiveMQCPP::shutdownLibrary();
} 
}



--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077852.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 12:33 -0800, mrdiesel wrote:
> you are right!!. i commented out shutdown library and I dont get that
> exception anymore. But now I get segmentation fault..:(( 
> 

My advice would be to look at the examples in the source package and see
how the code is organized such that the library is started and stopped
correctly and the CMS resources are free'd 

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -188941408 (LWP 28796)]
> 0xf7d7e255 in decaf::util::concurrent::Lock::lock (this=0xf4bcf0c0) at
> decaf/util/concurrent/Lock.cpp:54
> 54      decaf/util/concurrent/Lock.cpp: No such file or directory.
>         in decaf/util/concurrent/Lock.cpp
> Current language:  auto; currently c++
> 
> (gdb) backtrace
> #0  0xf7d7e255 in decaf::util::concurrent::Lock::lock (this=0xf4bcf0c0) at
> decaf/util/concurrent/Lock.cpp:54
> #1  0xf7d7e4db in Lock (this=0x313a, object=0xf40021b0, intiallyLocked=true)
> at decaf/util/concurrent/Lock.cpp:32
> #2  0xf794dfeb in activemq::core::ActiveMQConsumer::clearMessagesInProgress
> (this=0xf4002178) at activemq/core/ActiveMQConsumer.cpp:1112
> #3  0xf795ad7e in activemq::core::ActiveMQConsumer::dispatch
> (this=0xf4002178, dispatch=@0xf4bcf240) at
> activemq/core/ActiveMQConsumer.cpp:991
> #4  0xf79832cd in activemq::core::ActiveMQSessionExecutor::dispatch
> (this=0xf4001f08, dispatch=@0xf4bcf240) at
> activemq/core/ActiveMQSessionExecutor.cpp:129
> #5  0xf79835d0 in activemq::core::ActiveMQSessionExecutor::iterate
> (this=0xf4001f08) at activemq/core/ActiveMQSessionExecutor.cpp:166
> #6  0xf79dcc75 in activemq::threads::DedicatedTaskRunner::run
> (this=0x86b1558) at activemq/threads/DedicatedTaskRunner.cpp:111
> #7  0xf7d35392 in (anonymous namespace)::threadWorker (arg=0x87e9138) at
> decaf/lang/Thread.cpp:135
> #8  0x008f53cc in start_thread () from /lib/tls/libpthread.so.0
> #9  0x0080af0e in clone () from /lib/tls/libc.so.6
> 
> 
> now how can i resolve this?
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077794.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
you are right!!. i commented out shutdown library and I dont get that
exception anymore. But now I get segmentation fault..:(( 

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -188941408 (LWP 28796)]
0xf7d7e255 in decaf::util::concurrent::Lock::lock (this=0xf4bcf0c0) at
decaf/util/concurrent/Lock.cpp:54
54      decaf/util/concurrent/Lock.cpp: No such file or directory.
        in decaf/util/concurrent/Lock.cpp
Current language:  auto; currently c++

(gdb) backtrace
#0  0xf7d7e255 in decaf::util::concurrent::Lock::lock (this=0xf4bcf0c0) at
decaf/util/concurrent/Lock.cpp:54
#1  0xf7d7e4db in Lock (this=0x313a, object=0xf40021b0, intiallyLocked=true)
at decaf/util/concurrent/Lock.cpp:32
#2  0xf794dfeb in activemq::core::ActiveMQConsumer::clearMessagesInProgress
(this=0xf4002178) at activemq/core/ActiveMQConsumer.cpp:1112
#3  0xf795ad7e in activemq::core::ActiveMQConsumer::dispatch
(this=0xf4002178, dispatch=@0xf4bcf240) at
activemq/core/ActiveMQConsumer.cpp:991
#4  0xf79832cd in activemq::core::ActiveMQSessionExecutor::dispatch
(this=0xf4001f08, dispatch=@0xf4bcf240) at
activemq/core/ActiveMQSessionExecutor.cpp:129
#5  0xf79835d0 in activemq::core::ActiveMQSessionExecutor::iterate
(this=0xf4001f08) at activemq/core/ActiveMQSessionExecutor.cpp:166
#6  0xf79dcc75 in activemq::threads::DedicatedTaskRunner::run
(this=0x86b1558) at activemq/threads/DedicatedTaskRunner.cpp:111
#7  0xf7d35392 in (anonymous namespace)::threadWorker (arg=0x87e9138) at
decaf/lang/Thread.cpp:135
#8  0x008f53cc in start_thread () from /lib/tls/libpthread.so.0
#9  0x0080af0e in clone () from /lib/tls/libc.so.6


now how can i resolve this?

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077794.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-11-16 at 12:02 -0800, mrdiesel wrote:
> try{
>              if( session != NULL ) session->close();
>             if( connection != NULL ) connection->close();
>         }catch (CMSException& e) {e.printStackTrace();}
> 
> I m getting an exception as follows:
> 
> The Decaf Threading API is in a Shutdown State.
>         FILE: decaf/lang/Thread.cpp, LINE: 616
>         FILE: activemq/core/ActiveMQSession.cpp, LINE: 172
> 
> Why is this happening?
> 
> how can i avoid this? this is causing problems when i try to get more
> messages. 

My guess would be that you called shutdownLibrary before you destroyed
all the CMS resources, that's about the only reason I can think of that
you would be in this state.

> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077689.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

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




Re: The Decaf Threading API is in a Shutdown State. Exception

Posted by mrdiesel <mr...@gmail.com>.
And Sometimes, it justs hangs, it doesnt even throw exception, with JMX i
still can see there is a connection, which is not terminated yet.

--
View this message in context: http://activemq.2283324.n4.nabble.com/The-Decaf-Threading-API-is-in-a-Shutdown-State-Exception-tp4077689p4077694.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.