activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manua <agarwal.m...@gmail.com>
Subject Re: AMQ consumer, gives exception when executing query from mysql
Date Wed, 14 Jul 2010 15:05:13 GMT

Hi All,

The error is solved. There was no problem from ActiveMQ, it was only
catching the wrong catch block.

Thanks,
Manu


manua wrote:
> 
> Hi All,
> 
> My consumer gives unknown exception at,
> 
> mysqlpp::StoreQueryResult res = query.store()).
> 
> ON receiving the test message, I ma parsing and passing it to a function,
> which will dip the database on the basis of that parameter and returns the
> result.
> 
> I am able to parse the message and pass it to the required function.In the
> function, its able to connect to the database, but on query it gives the
> following exception,
> 
> caught unknown exception
>         FILE: activemq/core/ActiveMQConsumer.cpp, LINE: 987
>         FILE: activemq/core/ActiveMQSessionExecutor.cpp, LINE: 133
> 
> Please find below a code snippet of my code,
> 
> ===============================================================================
> 
> void onTicks( void *msg ){
> 	cout << get_ref_data("C");
> 	cout << "Msg received : " << endl;
> 
> 	const TextMessage* txtMessage = dynamic_cast< const TextMessage* >(
> (Message *)msg );
> 	string s1 = txtMessage->getText();
> 	istringstream is1(s1);
> 	Stream_reader<istringstream, mValue> reader(is1);
> 
> 	mValue value;
> 	reader.read_next(value);
> 	mObject& O = value.get_obj();
> 
> 	for(mObject::iterator it=O.begin();it != O.end();++it){
> 	    cout <<endl<< (it)->first;
> 	    if(!(it)->first.compare("Portfolio")){
> 	    	mArray& a = O["Portfolio"].get_array();
> 	    	for(int i=0;i<a.size();i++){
> 	    		mArray& tmp = a[i].get_array();
> 	    		cout << endl << "       ";
> 	    		string t = tmp[0].get_value<string>();
> 	    		try{
> 	    			get_ref_data(t);
> 	    			throw 0;
> 	    		}catch(const int n){
> 	    			cout << "Caught error " << n << endl;
> 	    		}....
>                         ..............
> 
> ===============================================================================
> 
> int get_ref_data(string s){
> 	mysqlpp::Connection conn;
> 	if (conn.connect("SecurityMaster", "localhost", "proddbuser",
> "proddblander")) {
> 		cout << "DB Connected" << "    string received : " << s <<
endl;
> 
> 		mysqlpp::Query query = conn.query();
> 		query << "SELECT * FROM table where symbol=" << s << " and
> date='20100628'";
> 		if (mysqlpp::StoreQueryResult res = query.store()) {
> 			cout << "Query Data:" << endl;
> 			for (size_t i = 0; i < res.num_rows(); ++i) {
> 				cout << '\t' << res[i][0] << " , "<< res[i][1] << "
, "<< res[i][2] <<
> " , "<< res[i][3] << " , "<< res[i][4] << endl;
> 			}
> 		}else{
> 			cout << "Couldn't execute the query";
> 		}
> 	}
> 	cout <<"query complete " << endl;
> 	return 1;
> }
> 
> ===============================================================================
> 
> Its connected to db, but after that gives error.
> 
> DB Connected    string received : C
> caught unknown exception
>         FILE: activemq/core/ActiveMQConsumer.cpp, LINE: 987
>         FILE: activemq/core/ActiveMQSessionExecutor.cpp, LINE: 133
> 
> ===============================================================================
> 
> What could be the reason for this or if I have to do it in a different
> way.
> 
> Kindly let me know your inputs.
> 
> Thanks,
> Manu
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/AMQ-consumer%2C-gives-exception-when-executing-query-from-mysql-tp29162123p29163050.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message